mareczek / international-phone-number

AngularJS directive implementing intl-tel-input (https://github.com/Bluefieldscom/intl-tel-input)
139 stars 131 forks source link

How grab dialCode to angular variable? #103

Closed BaurzhanSakhariev closed 2 years ago

BaurzhanSakhariev commented 8 years ago

I tried to use <input type="text" international-phone-number preferred-countries="kz" ng-model="data" country="countryData" required> but my countryData variable not populated.I rebuilt directive with separateDialCode: true (changed plugin javascript directly) and managed to get withput_dial to ng-model but didn't manage to get dialCode. How to do it?

I even tried to add my own variable to directive but couldn't find correct place to paste code like scope.myOwnVarInDirective = element.intlTelInput('getSelectedCountryData'). I tried to put such code in watch ngModel after ctrl.$modelValue = newValue; but failed - even simple debuggin cosole.log not triggered(

What is the place in directive where i should play with my own variable andd pass needed data? May be there exist already implemented way to grab dial code into angular variable?

kamleshpawar2006 commented 8 years ago

Hi BaurzhanSakhariev, Have you got the country code? i am also stuck on that. Please help.

zymr-keshav commented 7 years ago

try angular.element("#phone").intlTelInput("getSelectedCountryData") it will retun the object

Object {name: "United States", iso2: "us", dialCode: "1", priority: 0, areaCodes: null}