JavaScriptAngularJSConvert Number to Words Using Angular Library

Convert Number to Words Using Angular Library
C

An Angular library is an Angular project that is different from an application in which it cannot run on its own. A library must be imported and used in an application. Libraries extend the basic functionality of Angular.

It is a multi-language number to word converter that converts any number to words in your Angular app.

Convert Number to Words Using Angular Library

Supported Languages

  • en (English, default)
  • ar (Arabic)
  • cz (Czech)
  • dk (Danish)
  • de (German)
  • es (Spanish)
  • fr (French)
  • fa (Farsi)
  • he (Hebrew)
  • it (Italian)
  • ko (Korean)
  • lt (Lithuanian)
  • lv (Latvian)
  • nl (Dutch)
  • no (Norwegian)
  • pl (Polish)
  • pt (Portuguese)
  • ru (Russian)
  • sr (Serbian)
  • tr (Turkish)
  • uk (Ukrainian)

Installation

Install via npm. (Alternative)

Now install ngx-num-to-words via:

npm install --save n2words ngx-num-to-words

Import the library

If you installed the library via angular schematics, you can skip this step

import { NgxNumToWordsModule } from 'ngx-num-to-words'; 

@NgModule({
  declarations: [AppComponent, ...],
  imports: [NgxNumToWordsModule, ...],  
  bootstrap: [AppComponent]
})
export class AppModule {
}

Other modules in your application like for lazy loading import NgxNumToWordsModule into your feature module:

API

Using the service

<h1><b>{{numberInWords}}</b></h1>
import { NgxNumToWordsService, SUPPORTED_LANGUAGE } from 'ngx-num-to-words';


numberInWords!: string;
lang!: SUPPORTED_LANGUAGE = 'en';
value = 123;

 constructor(private ngxNumToWordsService: NgxNumToWordsService) {
  }


ngOnInit(): void {

    this.numberInWords = this.ngxNumToWordsService.inWords(value, this.lang);

 }

Using the pipe inWords

<span>{{ 123 | inWords }}</span> // default en language
<span>{{ 123 | inWords:'de' }}</span> // custom language --> german in this case

See live demo and download source code

This awesome script developed by AnthonyNahas. Visit their official repository for more information and follow for future updates.

Saroj Meher
Saroj Meherhttps://www.sarojmeher.com
Howdy! Friends, I am Saroj Meher. I am an Artist. I do Painting on mediums like Acrylic, Watercolour, Oil etc. I have over 7 years of experience in WordPress. I am currently running 30+ website. I am specialized in WordPress and WooCommerce, WordPress Theme Customization and Theme Development. I can fix any kind of WordPress error/issue like PHP, CSS, Js issues and other Theme and Plugin related issues. Client's Satisfaction is my first priority.

Subscribe For More!

Subscribe to get the Latest Updates directly in you Email box.

Explore More

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.

SAROJMEHER Photograph
I am a Lecturer (English & Sociology), a professional Artist, and a blogger. I do painting, sketches since my childhood. I am in the teaching for 10 years. In this teaching line, I have experience in teaching English at High School and College levels. I have also experienced teaching computer theory during the school teaching period. This is my personal web corner over the internet.

Quick Guides

7 Simple Steps To Start Your Blogging Journey

TRENDING TOPICS