ngx-numeral
Version:
An Angular pipe module for interfacing the Awesome Numeraljs library.
56 lines (41 loc) • 1.38 kB
Markdown
# ngx-numeral
[](https://badge.fury.io/js/ngx-numeral)
[](https://www.npmjs.com/package/ngx-numeral)
[](https://travis-ci.org/jogboms/ngx-numeral)
[](https://coveralls.io/github/jogboms/ngx-numeral?branch=master)
An Angular pipe module for interfacing the Awesome [Numeraljs](http://numeraljs.com/) library.
## Installation
```bash
npm i -S ngx-numeral
```
## Usage
Add `NumeralModule` to your application module.
```ts
@NgModule({
declarations: [
AppComponent
],
imports: [
NumeralModule.forRoot()
// ...
],
bootstrap: [AppComponent]
})
export class AppModule { }
```
Use Pipe within your template file
``` html
<h1>{{ '12345.123' | numeral:'$0,0.00' }}</h1>
```
Or instatiate `NumeralPipe` in your components with the desired value.
```ts
import { NumeralPipe } from 'ngx-numeral';
class ExampleComponent implements OnInit {
formatted_string: string;
ngOnInit() {
const numeral = new NumeralPipe('7784.374');
this.formatted_string = numeral.format('$0,0.00');
}
}
```
A demo application is also included.