angular/packages/examples/common/pipes/ts/number_pipe.ts
Matthieu Riegler 09df589e31 refactor(core): Migrate all packages with the explicit-standalone-flag schematic. (#58160)
All components, directives and pipes will now use standalone as default.
Non-standalone decorators have now `standalone: false`.

PR Close #58160
2024-10-14 14:58:57 +00:00

43 lines
1,002 B
TypeScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* @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} 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',
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: '0003,14159'-->
</p>
</div>`,
standalone: false,
})
export class NumberPipeComponent {
pi: number = 3.14159265359;
}
// #enddocregion