setNumber not setting the phone Number
Closed this issue · 0 comments
juvegitau commented
Steps to reproduce
- Create angular js directive
- Intialize the intelTelInput
- 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;
});
}
};
}]);
})();