Angular service/filter for phone number validation/display.
Type:
bower install ngPhone
Include the script:
<script src="bower_components/ng-phone/ng-phone.js"></script>
Add a depencency:
var myApp = angular.module('myApp', ['ngPhone']);
As a service:
myApp.controller('myController', function ($scope, ngPhone) {
$scope.phone = '+12125556666';
// Format
var formattedPhone = ngPhone.format($scope.phone, 'local', 'US');
// Validate
var isValid = ngPhone.isValidNumber($scope.phone, 'US');
});
See elad/libphonenumber for more format() examples.
As a filter:
<div>
{{ phone | phone:'local' }}
{{ phone | phone:'local':'US' }}
</div>
Behaves exactly like filter().
To sync with the latest version of libphonenumber
, type:
./build.sh