I\'ve searched here and there, and I am not able to find something specific about formatting a phone number.
Currently, I am retrieving phone numbers form a JSON in
You may use something like that in a custom Angular2 pipe:
switch (value.length) {
case 10:
country = 1;
city = value.slice(0, 3);
number = value.slice(3);
break;
case 11:
country = value[0];
city = value.slice(1, 4);
number = value.slice(4);
break;
case 12:
country = value.slice(0, 3);
city = value.slice(3, 5);
number = value.slice(5);
break;
default:
return tel;
}
Check this AngularJS out for more info, but as I said you need to convert it to Angular2:
http://jsfiddle.net/jorgecas99/S7aSj/