2016-06-23 09:47:54 -07:00
|
|
|
|
/**
|
|
|
|
|
* @license
|
2020-05-19 12:08:49 -07:00
|
|
|
|
* Copyright Google LLC All Rights Reserved.
|
2016-06-23 09:47:54 -07: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
|
|
|
|
|
*/
|
|
|
|
|
|
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';
|
|
|
|
|
|
2021-02-05 13:03:12 +07:00
|
|
|
|
registerLocaleData(localeFr, 'fr');
|
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>
|
2020-05-19 12:08:49 -07:00
|
|
|
|
|
2021-02-05 13:03:12 +07:00
|
|
|
|
<p>
|
|
|
|
|
No specified formatting:
|
|
|
|
|
{{pi | number}}
|
|
|
|
|
<!--output: '3.142'-->
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
With digitsInfo parameter specified:
|
|
|
|
|
{{pi | number:'4.1-5'}}
|
|
|
|
|
<!--output: '0,003.14159'-->
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
With digitsInfo and
|
|
|
|
|
locale parameters specified:
|
|
|
|
|
{{pi | number:'4.1-5':'fr'}}
|
|
|
|
|
<!--output: '0 003,14159'-->
|
|
|
|
|
</p>
|
2017-08-29 20:10:58 +02:00
|
|
|
|
|
2015-11-02 15:46:59 -08:00
|
|
|
|
</div>`
|
|
|
|
|
})
|
2016-09-08 21:41:09 -07:00
|
|
|
|
export class NumberPipeComponent {
|
2021-02-05 13:03:12 +07:00
|
|
|
|
pi: number = 3.14159265359;
|
2015-11-02 15:46:59 -08:00
|
|
|
|
}
|
|
|
|
|
// #enddocregion
|