Angular 2/4 pretty phone number pipe
When working with phone numbers, google made it easy by creating libphonenumber. It does all the work horse about parsing and formatting phone numbers according to their prefixes.
This library is a simpler version of the library and very handy in our case.
We suppose we use https://www.npmjs.com/package/@angular/cli for the project. We have to add the library to the current project:
$ npm install --save libphonenumber-js
Then, we can the following piece of code in a pipe file.
here we have a very simple pipe that will format any parsed phone number.
Using this pipe is straightforward in html:
All there is to do, is parsing phone numbers using forms (coming soon).