VIshnu
VIshnu

Reputation: 23

Showing error angular.js:12477 TypeError: $(...).intlTelInput is not a function

I have a tab service provider which shows details of a customer. When you click the tab, it shows empty fields to edit and gives this error

angular.js:12477 TypeError: $(...).intlTelInput is not a function

After refreshing the page, the error disappears. What could be the issue?

I have put my intlTelInput function inside a timeout function but it didn't work.

This is my code

if ($("input[name='code']").length >= 1) {
    $("input[name='code']").intlTelInput({
        separateDialCode: true,
        initialCountry: "auto",
        geoIpLookup: function (callback) {
            $.getJSON("https://freegeoip.net/json/", function (data) {
                callback(data.country_code); `
            });
        }
    });
}

This is the complete error

angular.js:12477 TypeError: $(...).intlTelInput is not a function at Object. (http://localhost/taskm-rio/public/admin/app/ng-controllers/providerController.js:104:49)

enter image description here

Upvotes: 1

Views: 2034

Answers (1)

AMAL MOHAN N
AMAL MOHAN N

Reputation: 1622

Add utils.js in scripts,

`"scripts": [ 
              "node_modules/intl-tel-input/build/js/utils.js"
            ]`

in angular.json file. This will solve your issue.

  1. goto angular.json file
  2. look for scripts
  3. add "node_modules/intl-tel-input/build/js/utils.js" inside the scripts along with the intlTelInput.min.js / intlTelInput.js
  4. save
  5. refresh your application

Upvotes: 1

Related Questions