angular-telephone-filter
☎️ 🇺🇸 A simple AngularJS filter to clean or format a US telephone number.
Comments and Pull Requests welcome!
Contents
Installation
NPM
$ npm install angular-telephone-filter --save
Bower
$ bower install angular-telephone-filter --save
Or, include the JavaScript file in the head of your document:
Include the module as a dependency of your application:
angular;
Dependencies
- Angular.js (^1.4.0)
Usage
The filter expects a single parameter to be passed in to control the filter direction. A parameter
of clean
will return only the numbers (ie 1235551234
) while the format
parameter will direct
the filter to output the formatted number (ie (123) 555-1234
);
Use in HTML:
{{'4045551234' | bcTelephone:'format'}}<!-- Outputs: <p>(404) 555-1234</p> --> {{'(404) 555-1234' | bcTelephone:'clean'}}<!-- Outputs: <p>4045551234</p> -->
Use in a controller
{ const prettyNumber = '(404) 555-1234'; prettyNumber 'clean'; // Output: 4045551234 const cleanNumber = '4045551234'; cleanNumber 'format'; // Output: (404) 555-1234 }
Development
npm run build
- produces production version of your library under thedist
foldernpm run dev
- produces development version of your library under thedist
folder and runs a watcher