A TypeScript library, designed to convert any numeric number into its corresponding representation in words. The pipe comes in two numbering systems, The Indian Numbering System and The International Numbering System. This powerful pipe eliminates the need for developers to manually implement the logic, saving development time and enabling a faster and more focused development process. Particularly useful in generating invoices, generating reports, or presenting numeric data to end-users in a more friendly and understandable way.
-
Run the following command at the root of your project:
npm install ngx-custom-pipe
This will install the ngx-custom-pipe
package as a project dependency in the node_modules folder.
-
Import the NgxCustomPipeModule module in your *.module.ts:
import { NgxCustomPipeModule } from 'ngx-custom-pipe';
-
Add the NgxCustomPipeModule module to the
imports
array of your@NgModule
decorator:import { NgxCustomPipeModule } from 'ngx-custom-pipe'; @NgModule({ // ... imports: [ // ... NgxCustomPipeModule ] })
-
Pipes can also be injected into components or services. Declare the pipe in the providers array of your
*.module.ts
or*.component.ts
:For example:
import { NgxCustomPipe } from 'ngx-custom-pipe'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'], providers: [NumberToWordsPipe] }) export class AppComponent { title = 123456789; constructor(private numberToWordsPipe: NumberToWordsPipe) { console.log(this.numberToWordsPipe.transform(this.title)); } }
NOTE: By default, the pipe uses the International Numbering System. To use the Indian Numbering System, pass
'INR'
as a parameter to the pipe.For example:
import { NgxCustomPipe } from 'ngx-custom-pipe'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'], providers: [NumberToWordsPipe] }) export class AppComponent { title = 123456789; constructor(private numberToWordsPipe: NumberToWordsPipe) { console.log(this.numberToWordsPipe.transform(this.title, 'INR')); } }
-
Pipes can also be used in templates.
<p>{{ 1234567890 | numberToWords }}</p>
To use the Indian Numbering System, pass
'INR'
as a parameter to the pipe.<p>{{ 1234567890 | numberToWords: 'INR' }}</p>
To contribute to this project, please read the CONTRIBUTING.md file.
This project is licensed under the BSD 3-Clause License - see the LICENSE file for details.