Skip to content

elad/ng-phone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ng-phone

Angular service/filter for phone number validation/display.

Install

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']);

Use

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().

Update

To sync with the latest version of libphonenumber, type:

./build.sh

About

Angular service/filter for phone number validation/display

Resources

Stars

Watchers

Forks

Packages

No packages published