Created
May 2, 2015 20:15
-
-
Save erberg-snippets/ce2a15f47a268712fb26 to your computer and use it in GitHub Desktop.
Angular Phone Number Filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.filter('phoneNumber', function(){ | |
return function(input){ | |
if(input && (input.length === 7)){ | |
return input.substr(0,3) + '-' + input.substr(3,7); | |
} else if(input.length === 10){ | |
console.log(input); | |
return '(' + input.substr(0,3) + ') ' + input.substr(3,3) + '-' + input.substr(6,4); | |
} | |
return input; | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment