Created
June 18, 2018 07:27
-
-
Save Theasker/97b81f122fa24dae94ec865a44236a75 to your computer and use it in GitHub Desktop.
Angular number pipe with locale Internationalization (i18n)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Component, OnInit, LOCALE_ID } from '@angular/core'; | |
| //import { merge } from 'rxjs'; | |
| //import { MyCurrencyFormatterDirective } from "./directivas/my-currency-formatter.directive"; | |
| // Locales para number pipe | |
| import { registerLocaleData } from '@angular/common'; | |
| import es from '@angular/common/locales/es'; | |
| registerLocaleData(es, 'es'); | |
| @Component({ | |
| selector: 'app-root', | |
| template: `Number pipe: {{ num | number }}`, | |
| styleUrls: ['./app.component.css'], | |
| providers: [ | |
| { provide: LOCALE_ID, useValue: 'es' }, | |
| ] | |
| }) | |
| export class AppComponent implements OnInit { | |
| public num: number = 123456.78; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment