jackocnr/intl-tel-input

setNumber not setting the phone Number

Closed this issue · 0 comments

Steps to reproduce

  1. Create angular js directive
  2. Intialize the intelTelInput
  3. setNumber
    see code below

Expected behaviour

when i call getNumber() i expect to get the phone number

import intlTelInput from 'intl-tel-input';
(function () {
'use strict';

angular.module('estimate')
.directive('intlTelInput', ["$timeout",
function ($timeout) {
return {
restrict: 'A',
require: 'ngModel',
link: function (scope, elm, attr, ctrl) {
$timeout(function () {
//ctrl.$validate();
});
var options = {
initialCountry: 'ke',
preferredCountries: ['ke', 'ug', 'tz'],
showFlags: false,
utilsScript: "/scripts/app-build/utils.js"
}
var inputElement = elm[0];
debugger
var iti = intlTelInput(inputElement, options);
ctrl.$validators.ngIntlTelInput = function (value) {
var sss = iti.getNumber();

          if (value) {
            return iti.isValidNumber();;

          } else {
            return true;
          }
        };

        ctrl.$parsers.push(function (value) {
          return iti.getNumber();;

        });
        ctrl.$formatters.push(function (modelValue) {


          iti.setNumber(modelValue);


          return modelValue;
        });


      }
    };
  }]);

})();