How to get country code with ng-intl-tel-input directive

3.1k Views Asked by At

How to get country code from input type in Angularjs

I am new in Angularjs, right now I have dropdown of country code + input type text (for mobile number), after a click on submit button, I am getting mobile number successfully but how can I get the country code as well? Here is my HTML code

<input type="tel" class="form-control" id="tel" name="tel" 
       ng-model="updating.phone" ng-intl-tel-input numbers-only
       data-selected-country="selected.country" style="width:100%;">

Here is my script code

function getviewed()
{
    var form = new FormData();
    var numbr = document.getElementById('tel').value;
 }

Editors note:

The GitHub for the ng-intl-tel-input directive is https://github.com/hodgepodgers/ng-intl-tel-input

1

There are 1 best solutions below

0
On

Try this:

angular.element("#tel").intlTelInput.getSelectedCountryData()