A directive to format phone number
I was wondering how to automatically format a number in an input field using an angularjs directive? When I type in an input field say 6042919283 I want it to be shown as 604-291-9283. Thanks You could use UI Utils mask It allows you to define an allowd input format and will handle the validation for you as well as the formatting If your phone number is uniform i.e all the number is of digit 10 this one will work app.directive('formatPhone', [ function() { return { require: 'ngModel', restrict: 'A', link: function(scope, elem, attrs, ctrl, ngModel) { elem.add(phonenumber).on('keyup', function(