| 
									
										
										
										
											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
 | 
					
						
							|  |  |  |  |  */ | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-29 20:10:58 +02:00
										 |  |  |  | import {registerLocaleData} from '@angular/common'; | 
					
						
							| 
									
										
										
										
											2016-09-27 17:12:25 -07:00
										 |  |  |  | import {Component} from '@angular/core'; | 
					
						
							| 
									
										
										
										
											2017-08-29 20:10:58 +02:00
										 |  |  |  | // we need to import data for the french locale
 | 
					
						
							|  |  |  |  | import localeFr from './locale-fr'; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | // registering french data
 | 
					
						
							|  |  |  |  | registerLocaleData(localeFr); | 
					
						
							| 
									
										
										
										
											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>
 | 
					
						
							| 
									
										
										
										
											2017-08-29 20:10:58 +02:00
										 |  |  |  |     <!--output '2.718'--> | 
					
						
							|  |  |  |  |     <p>e (no formatting): {{e | number}}</p> | 
					
						
							|  |  |  |  |      | 
					
						
							|  |  |  |  |     <!--output '002.71828'--> | 
					
						
							| 
									
										
										
										
											2015-11-02 15:46:59 -08:00
										 |  |  |  |     <p>e (3.1-5): {{e | number:'3.1-5'}}</p> | 
					
						
							| 
									
										
										
										
											2017-08-29 20:10:58 +02:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |     <!--output '0,002.71828'--> | 
					
						
							| 
									
										
										
										
											2017-12-06 12:05:24 +08:00
										 |  |  |  |     <p>e (4.5-5): {{e | number:'4.5-5'}}</p> | 
					
						
							| 
									
										
										
										
											2017-08-29 20:10:58 +02:00
										 |  |  |  |      | 
					
						
							|  |  |  |  |     <!--output '0 002,71828'--> | 
					
						
							|  |  |  |  |     <p>e (french): {{e | number:'4.5-5':'fr'}}</p> | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     <!--output '3.14'--> | 
					
						
							| 
									
										
										
										
											2017-12-06 12:05:24 +08:00
										 |  |  |  |     <p>pi (no formatting): {{pi | number}}</p> | 
					
						
							| 
									
										
										
										
											2017-08-29 20:10:58 +02:00
										 |  |  |  |      | 
					
						
							|  |  |  |  |     <!--output '003.14'--> | 
					
						
							| 
									
										
										
										
											2017-12-06 12:05:24 +08:00
										 |  |  |  |     <p>pi (3.1-5): {{pi | number:'3.1-5'}}</p> | 
					
						
							| 
									
										
										
										
											2017-08-29 20:10:58 +02:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |     <!--output '003.14000'--> | 
					
						
							| 
									
										
										
										
											2017-12-06 12:05:24 +08:00
										 |  |  |  |     <p>pi (3.5-5): {{pi | number:'3.5-5'}}</p> | 
					
						
							| 
									
										
										
										
											2018-06-29 08:38:39 +02:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |     <!--output '-3' / unlike '-2' by Math.round()--> | 
					
						
							|  |  |  |  |     <p>-2.5 (1.0-0): {{-2.5 | number:'1.0-0'}}</p> | 
					
						
							| 
									
										
										
										
											2015-11-02 15:46:59 -08:00
										 |  |  |  |   </div>`
 | 
					
						
							|  |  |  |  | }) | 
					
						
							| 
									
										
										
										
											2016-09-08 21:41:09 -07:00
										 |  |  |  | export class NumberPipeComponent { | 
					
						
							| 
									
										
										
										
											2017-08-29 20:10:58 +02:00
										 |  |  |  |   pi: number = 3.14; | 
					
						
							| 
									
										
										
										
											2015-11-02 15:46:59 -08:00
										 |  |  |  |   e: number = 2.718281828459045; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | // #enddocregion
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-29 20:10:58 +02:00
										 |  |  |  | // #docregion DeprecatedNumberPipe
 | 
					
						
							| 
									
										
										
										
											2015-11-02 15:46:59 -08:00
										 |  |  |  | @Component({ | 
					
						
							| 
									
										
										
										
											2017-08-29 20:10:58 +02:00
										 |  |  |  |   selector: 'deprecated-number-pipe', | 
					
						
							| 
									
										
										
										
											2015-11-02 15:46:59 -08:00
										 |  |  |  |   template: `<div>
 | 
					
						
							| 
									
										
										
										
											2017-08-29 20:10:58 +02:00
										 |  |  |  |     <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> | 
					
						
							| 
									
										
										
										
											2015-11-02 15:46:59 -08:00
										 |  |  |  |   </div>`
 | 
					
						
							|  |  |  |  | }) | 
					
						
							| 
									
										
										
										
											2017-08-29 20:10:58 +02:00
										 |  |  |  | export class DeprecatedNumberPipeComponent { | 
					
						
							|  |  |  |  |   pi: number = 3.141592; | 
					
						
							|  |  |  |  |   e: number = 2.718281828459045; | 
					
						
							| 
									
										
										
										
											2015-11-02 15:46:59 -08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | // #enddocregion
 |