| 
									
										
										
										
											2016-06-23 09:47:54 -07:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @license | 
					
						
							|  |  |  |  * Copyright Google Inc. All Rights Reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Use of this source code is governed by an MIT-style license that can be | 
					
						
							|  |  |  |  * found in the LICENSE file at https://angular.io/license
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-27 17:12:25 -07:00
										 |  |  | import {Component} from '@angular/core'; | 
					
						
							| 
									
										
										
										
											2015-11-02 15:46:59 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | // #docregion NumberPipe
 | 
					
						
							|  |  |  | @Component({ | 
					
						
							| 
									
										
										
										
											2016-09-08 21:41:09 -07:00
										 |  |  |   selector: 'number-pipe', | 
					
						
							| 
									
										
										
										
											2015-11-02 15:46:59 -08:00
										 |  |  |   template: `<div>
 | 
					
						
							|  |  |  |     <p>e (no formatting): {{e}}</p> | 
					
						
							|  |  |  |     <p>e (3.1-5): {{e | number:'3.1-5'}}</p> | 
					
						
							|  |  |  |     <p>pi (no formatting): {{pi}}</p> | 
					
						
							|  |  |  |     <p>pi (3.5-5): {{pi | number:'3.5-5'}}</p> | 
					
						
							|  |  |  |   </div>`
 | 
					
						
							|  |  |  | }) | 
					
						
							| 
									
										
										
										
											2016-09-08 21:41:09 -07:00
										 |  |  | export class NumberPipeComponent { | 
					
						
							|  |  |  |   pi: number = 3.141592; | 
					
						
							| 
									
										
										
										
											2015-11-02 15:46:59 -08:00
										 |  |  |   e: number = 2.718281828459045; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | // #enddocregion
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // #docregion PercentPipe
 | 
					
						
							|  |  |  | @Component({ | 
					
						
							| 
									
										
										
										
											2016-09-08 21:41:09 -07:00
										 |  |  |   selector: 'percent-pipe', | 
					
						
							| 
									
										
										
										
											2015-11-02 15:46:59 -08:00
										 |  |  |   template: `<div>
 | 
					
						
							|  |  |  |     <p>A: {{a | percent}}</p> | 
					
						
							|  |  |  |     <p>B: {{b | percent:'4.3-5'}}</p> | 
					
						
							|  |  |  |   </div>`
 | 
					
						
							|  |  |  | }) | 
					
						
							| 
									
										
										
										
											2016-09-08 21:41:09 -07:00
										 |  |  | export class PercentPipeComponent { | 
					
						
							| 
									
										
										
										
											2015-11-02 15:46:59 -08:00
										 |  |  |   a: number = 0.259; | 
					
						
							|  |  |  |   b: number = 1.3495; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | // #enddocregion
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // #docregion CurrencyPipe
 | 
					
						
							|  |  |  | @Component({ | 
					
						
							| 
									
										
										
										
											2016-09-08 21:41:09 -07:00
										 |  |  |   selector: 'currency-pipe', | 
					
						
							| 
									
										
										
										
											2015-11-02 15:46:59 -08:00
										 |  |  |   template: `<div>
 | 
					
						
							|  |  |  |     <p>A: {{a | currency:'USD':false}}</p> | 
					
						
							|  |  |  |     <p>B: {{b | currency:'USD':true:'4.2-2'}}</p> | 
					
						
							|  |  |  |   </div>`
 | 
					
						
							|  |  |  | }) | 
					
						
							| 
									
										
										
										
											2016-09-08 21:41:09 -07:00
										 |  |  | export class CurrencyPipeComponent { | 
					
						
							| 
									
										
										
										
											2015-11-02 15:46:59 -08:00
										 |  |  |   a: number = 0.259; | 
					
						
							|  |  |  |   b: number = 1.3495; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | // #enddocregion
 |