Solved – intlTelInput is not a function

Angular 8 input phone number with country code

Hello to all, welcome to therichpost.com. In this post, I will solved – intlTelInput is not a function.

From last couple of months, I am getting questions from my blog and youtube viewers that, during implement input phone number with country code, they are facing many error like below:

  • window.intlTelInput is not a function
  • intlTelInput is not a function
  • ERROR TypeError: ctx.telInputObject is not a function

Here is the proper tutorial to add input type phone number into your angular 9 application but you need to replace the component.html file with my code and that code I have mentioned in the end:

1. Here is the code, you just need to replace:

<input  type="text" ng2TelInput (hasError)="hasError($event)" (ng2TelOutput)="getNumber($event)" (intlTelInputObject)="telInputObject($event)" 
 (countryChange)="onCountryChange($event)" />





//You need to remove all the functions because first you have to declare them all in component.ts file
----To---- //For using default events you just need to declare functions into your component.ts file as well






<input  type="text" ng2TelInput  />

If you are still facing issue then please comment below.

jassa

Thank you

Comments

46 responses to “Solved – intlTelInput is not a function”

  1. Lynn Avatar
    Lynn

    Hi, Im getting an error as shown as below, Im using angular 8

    Refused to apply style from ‘http://localhost:4200/path/to/intlTelInput.css’ because its MIME type (‘text/html’) is not a supported stylesheet MIME type, and strict MIME checking is enabled.

    can u pls help?

  2. Ajay Malhotra Avatar

    Hi Lynn, did you follow this tutorial and i think you have not applied styles:
    https://therichpost.com/angular-8-input-phone-number-with-country-code/

  3. Bilgin Kılıç Avatar
    Bilgin Kılıç

    how to set 90 country code and 05552456800 to number field. I want to initialize this with these values. But how? thank you

  4. Ajay Malhotra Avatar

    Hi, you want default 90?

  5. Bilgin Kılıç Avatar
    Bilgin Kılıç

    Imagine when you visit the page you see indian flag is set and number is 05552456800 , how can i set these variables into the object.

  6. Bilgin Kılıç Avatar
    Bilgin Kılıç

    I mean I want to set country code when I initialize the object. 90 is Turkey ‘s country code.

  7. Ajay Malhotra Avatar

    Here is the code:
    add this attribute inside input

    [ng2TelInputOptions]=”{initialCountry: ‘in’}”

  8. anjali Avatar
    anjali

    how can i change dynamical value for country code

  9. Ajay Malhotra Avatar

    Yes, you can. you need to define that value into your controller file.

    Thank you

  10. Dhairya Avatar
    Dhairya

    How will i get the value concating country code and number

  11. Ajay Malhotra Avatar

    For this, you need to call input onchange event.

  12. Dhairya Avatar
    Dhairya

    can i use this with formly angular 7

  13. Anjali Jibhakate Avatar
    Anjali Jibhakate

    Hi, Im getting same error vendor.js:1824 ERROR Error: Uncaught (in promise): TypeError: window.intlTelInput is not a function ..please help

  14. Ajay Malhotra Avatar

    Hi, can you please show me your code?

  15. Akhil Jain Avatar
    Akhil Jain

    I have followed your step one by one but getting the same issue.
    intltelinput function not found.
    type of text/html (Refused to apply style from ‘http://localhost:4200/node_modules/intl-tel-input/build/css/intlTelInput.css’ because its MIME type (‘text/html’) is not a supported stylesheet MIME type, and strict MIME checking is enabled.)
    ERROR TypeError: window.intlTelInput is not a function
    plz help

  16. Akhil Jain Avatar
    Akhil Jain

    yes, sir.
    I have followed the same step given in this URL.In my angular 5 version projects.

  17. Ajay Malhotra Avatar

    Your are doing in angular 5? very old, right now angular 9 is running.

  18. Akhil Jain Avatar
    Akhil Jain

    but my project on angular 5.Plz suggest

  19. Ajay Malhotra Avatar

    Angular 5 is older version, please do project in Angular 9.

  20. Akhil Jain Avatar
    Akhil Jain

    that is not my project it is my client (office) project which is running on angular 5 so that I am getting an issue and I didn’t find other packages dependency.

  21. Ajay Malhotra Avatar

    Yes you are right then you can use some other jquery library for input with country selection.

  22. Akhil Jain Avatar
    Akhil Jain

    thanks .. now it’s working on my same project but how validate the number country wise.
    and save that data with fromControlName.

  23. Dhairya Avatar
    Dhairya

    How to use with ngx formly angular can u give solution

  24. Ajay Malhotra Avatar

    I will update you on this.

  25. sirinu Avatar
    sirinu

    Hi, I am using angular 8 version but get some error.

    window.intlTelInput is not a function

  26. sirinu Avatar
    sirinu

    in local its working fine, after the move to live its coming error.

  27. Ajay Malhotra Avatar

    Did you follow my complete tutorial?

  28. Hashan94 Avatar
    Hashan94

    it works. Thanks a lot!!!!

  29. Maheswari Avatar
    Maheswari

    Hi is there any option for search country field

  30. madhavi Avatar
    madhavi

    Hi, i need same functionality in angular 9 using ag-grid. Is it possible

  31. Mounica Chandra Avatar
    Mounica Chandra

    Hi, I am setting the number for inttelinputobject, here countrycode with flag is coming but I am not getting phonenumber in input field

  32. Mounica Chandra Avatar
    Mounica Chandra

    How do I seperate a country code from phonenumber?

  33. Ajay Malhotra Avatar

    Can you explain it bit more?

  34. Mounica Chandra Avatar
    Mounica Chandra

    I am having a input field of type tel it contains both country code with flag and phonenumber field, so while I am saving the number I am sending both countrycode and phonenumber in one string, while I am editing the page I am getting phonenumber as both countrycode and phonenumber.
    so I need to set the number what I get, while setting the number by using setNumber() only country code is setting, phone number is not setting

  35. Ajay Malhotra Avatar

    Okay, I will check and update you. Thanks

  36. Maheswari Avatar
    Maheswari

    Hi Thank you for the reply can you please provide the code(property for searching the country using intltelinput) so that i can implement it in my application

  37. amalmohann Avatar
    amalmohann

    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

  38. Maddela Sandeep Avatar
    Maddela Sandeep

    its works only locally but when we try to build in server and load it it will how same error

  39. Ajay Malhotra Avatar

    You must have some undefined function.

  40. Supradha Avatar
    Supradha

    Hey,Ng2-tel-Input in not working with angular 12

  41. therichpost Avatar

    Can you please tell me your error in console?