Angular Library to convert number to words | Angular Tutorial
SoftwareTechIT
Posted on March 15, 2023
A simple angularjs based library to convert number to word, it also support multi language that helps to convert any number into different different languages words.
A multi-language number to word converter that converts any number to words in your Angular app.
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)
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
Read More :-
https://softwaretechit.com/web-stories/10-best-angular-ui-libraries-angular-ui-compo/
https://softwaretechit.com/category/web-development/angular/
https://softwaretechit.com/call-web-api-from-angular-8-example-api-in-angular-create-website/
Dev.to:
https://dev.to/softwaretechit/angular-library-to-convert-number-to-words-angular-tutorial-cl7
https://dev.to/softwaretechit/angular-part-1-creating-angular-project-eaccessoriesshop-setup-project-angular-project-ecommerce-12jh
Posted on March 15, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.