☎️ 🇺🇸 A simple AngularJS filter to clean or format a US telephone number.
Comments and Pull Requests welcome!
$ npm install angular-telephone-filter --save$ bower install angular-telephone-filter --saveOr, include the JavaScript file in the head of your document:
<script src="/path/to/file/angular-telephone-filter.js"></script>Include the module as a dependency of your application:
angular.module('myModule', ['bc.TelephoneFilter']);- Angular.js (^1.4.0)
 
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);
<p>{{'4045551234' | bcTelephone:'format'}}</p>
<!-- Outputs: <p>(404) 555-1234</p> -->
<p>{{'(404) 555-1234' | bcTelephone:'clean'}}</p>
<!-- Outputs: <p>4045551234</p> -->function myController($filter) {
  const prettyNumber = '(404) 555-1234';
  $filter('bcTelephone')(prettyNumber, 'clean'); // Output: 4045551234
  const cleanNumber = '4045551234';
  $filter('bcTelephone')(cleanNumber, 'format'); // Output: (404) 555-1234
}npm run build- produces production version of your library under thedistfoldernpm run dev- produces development version of your library under thedistfolder and runs a watcher