international-phone-number icon indicating copy to clipboard operation
international-phone-number copied to clipboard

Save/use selected country

Open geoffreyvd opened this issue 9 years ago • 5 comments

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.

geoffreyvd avatar Jan 24 '16 13:01 geoffreyvd

Duplicate of #70

GaloisGirl avatar Feb 08 '16 10:02 GaloisGirl

@GaloisGirl thank you for the answer..!

geoffreyvd avatar Feb 09 '16 18:02 geoffreyvd

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.

GaloisGirl avatar Feb 09 '16 19:02 GaloisGirl

Awesome, thank you!

geoffreyvd avatar Feb 09 '16 19:02 geoffreyvd

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

leonardlu avatar Feb 16 '16 07:02 leonardlu