Skip to content

HamdaanAliQuatil/ngx-custom-pipe

ngx-custom-pipe

npm NPM Downloads NPM Downloads License: BSD-3-Clause GitHub issues

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.

Table of contents

Installation

  1. 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.

Usage

  1. Import the NgxCustomPipeModule module in your *.module.ts:

     import { NgxCustomPipeModule } from 'ngx-custom-pipe';
    
  2. Add the NgxCustomPipeModule module to the imports array of your @NgModule decorator:

     import { NgxCustomPipeModule } from 'ngx-custom-pipe';
    
     @NgModule({
         // ...
         imports: [
         // ...
         NgxCustomPipeModule
         ]
     })
    
  3. 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'));
         }
     }
    
  4. 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>
    

Contributing

To contribute to this project, please read the CONTRIBUTING.md file.

License

This project is licensed under the BSD 3-Clause License - see the LICENSE file for details.

About

A custom pipe for Angular Developers

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published