mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
7345bdc06b
Updated pipe examples to explicitly import the pipe for clarity and correctness. Also removed `standalone: true` since it is now the default and no longer necessary. PR Close #64135
44 lines
1020 B
TypeScript
44 lines
1020 B
TypeScript
/**
|
||
* @license
|
||
* Copyright Google LLC 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.dev/license
|
||
*/
|
||
|
||
import {registerLocaleData, DecimalPipe} from '@angular/common';
|
||
import {Component} from '@angular/core';
|
||
// we need to import data for the french locale
|
||
import localeFr from './locale-fr';
|
||
|
||
registerLocaleData(localeFr, 'fr');
|
||
|
||
// #docregion NumberPipe
|
||
@Component({
|
||
selector: 'number-pipe',
|
||
imports: [DecimalPipe],
|
||
template: `<div>
|
||
<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>
|
||
</div>`,
|
||
})
|
||
export class NumberPipeComponent {
|
||
pi: number = 3.14159265359;
|
||
}
|
||
// #enddocregion
|