mareczek / international-phone-number

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

Save/use selected country #88

Open geoffreyvd opened 8 years ago

geoffreyvd commented 8 years ago

So I am not sure if it's just me, but I can't find out how to use the selected Country code. I don't really get it, I mean why can a user select a country while it won't be even used/saved?!

So I want to use this repository but really need this to work, thanks in advance, like to hear from u asap.

GaloisGirl commented 8 years ago

Duplicate of #70

geoffreyvd commented 8 years ago

@GaloisGirl thank you for the answer..!

GaloisGirl commented 8 years ago

I was looking for the same answer and I ended up using another directive instead: https://github.com/hodgepodgers/ng-intl-tel-input. Its model is the full phone number, country code included.

geoffreyvd commented 8 years ago

Awesome, thank you!

leonardlu commented 8 years ago

To obtain the country code, you can use element.intlTelInput("getSelectedCountryData"), and return this value in your directive

it will return something like this:

{ name: "Afghanistan (‫افغانستان‬‎)", iso2: "af", dialCode: "93" }

Source: https://github.com/jackocnr/intl-tel-input#options