Reputation: 313
how to use intl-tel-input(https://github.com/Bluefieldscom/intl-tel-input) jquery plugin in my angular app to format mobile number field.
Upvotes: 0
Views: 125
Reputation: 6206
You need to load jQuery and wrap it in a directive.
Directive Def:
app.directive('intlTel', function(){
return{
replace:true,
restrict: 'E',
require: 'ngModel',
template: '<input type="text" placeholder="e.g. +1 702 123 4567">',
link: function(scope,element,attrs,ngModel){
var read = function() {
var inputValue = element.val();
ngModel.$setViewValue(inputValue);
}
element.intlTelInput({
defaultCountry:'fr',
});
element.on('focus blur keyup change', function() {
scope.$apply(read);
});
read();
}
}
});
Use:
<intl-tel ng-model="model.telnr"></intl-tel>
Watch this Plunker
Upvotes: 1