| 
									
										
										
										
											2017-08-29 20:10:58 +02:00
										 |  |  |  | /** | 
					
						
							|  |  |  |  |  * @license | 
					
						
							| 
									
										
										
										
											2020-05-19 12:08:49 -07:00
										 |  |  |  |  * Copyright Google LLC All Rights Reserved. | 
					
						
							| 
									
										
										
										
											2017-08-29 20:10:58 +02:00
										 |  |  |  |  * | 
					
						
							|  |  |  |  |  * 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
 | 
					
						
							|  |  |  |  |  */ | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | import {registerLocaleData} from '@angular/common'; | 
					
						
							|  |  |  |  | import {Component} from '@angular/core'; | 
					
						
							|  |  |  |  | // we need to import data for the french locale
 | 
					
						
							|  |  |  |  | import localeFr from './locale-fr'; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | // registering french data
 | 
					
						
							|  |  |  |  | registerLocaleData(localeFr); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | // #docregion CurrencyPipe
 | 
					
						
							|  |  |  |  | @Component({ | 
					
						
							|  |  |  |  |   selector: 'currency-pipe', | 
					
						
							|  |  |  |  |   template: `<div>
 | 
					
						
							| 
									
										
										
										
											2018-06-25 20:05:00 +02:00
										 |  |  |  |     <!--output '$0.26'--> | 
					
						
							| 
									
										
										
										
											2017-08-29 20:10:58 +02:00
										 |  |  |  |     <p>A: {{a | currency}}</p> | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     <!--output 'CA$0.26'--> | 
					
						
							|  |  |  |  |     <p>A: {{a | currency:'CAD'}}</p> | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     <!--output 'CAD0.26'--> | 
					
						
							|  |  |  |  |     <p>A: {{a | currency:'CAD':'code'}}</p> | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     <!--output 'CA$0,001.35'--> | 
					
						
							|  |  |  |  |     <p>B: {{b | currency:'CAD':'symbol':'4.2-2'}}</p> | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     <!--output '$0,001.35'--> | 
					
						
							|  |  |  |  |     <p>B: {{b | currency:'CAD':'symbol-narrow':'4.2-2'}}</p> | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     <!--output '0 001,35 CA$'--> | 
					
						
							|  |  |  |  |     <p>B: {{b | currency:'CAD':'symbol':'4.2-2':'fr'}}</p> | 
					
						
							| 
									
										
										
										
											2018-06-25 20:05:00 +02:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |     <!--output 'CLP1' because CLP has no cents--> | 
					
						
							|  |  |  |  |     <p>B: {{b | currency:'CLP'}}</p> | 
					
						
							| 
									
										
										
										
											2017-08-29 20:10:58 +02:00
										 |  |  |  |   </div>`
 | 
					
						
							|  |  |  |  | }) | 
					
						
							|  |  |  |  | export class CurrencyPipeComponent { | 
					
						
							|  |  |  |  |   a: number = 0.259; | 
					
						
							|  |  |  |  |   b: number = 1.3495; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | // #enddocregion
 |