GithubHelp home page GithubHelp logo

ng2-tel-input's Introduction

This repository is no longer maintained.

Angular 2+ wrapper for intl-tel-input

Installation

Run following command to install ng2-tel-input

npm install ng2-tel-input intl-tel-input --save

After install, you need to add intlTelInput.css, intlTelInput.min.js, utils.js.

In case of @angular/cli, add 2 files in your angular.json.

For example,

  • Include intlTelInput.css in "styles" at your angular.json file :
  "styles": [
    ...
    "node_modules/intl-tel-input/build/css/intlTelInput.css",
    ...
  ]
  • Include intlTelInput.min.js, utils.js in "scripts" at your angular.json file :
  "scripts": [
    ...
    "node_modules/intl-tel-input/build/js/intlTelInput.min.js"
    ...
  ]

Now add Ng2TelInputModule into your AppModule. For example,

import {Ng2TelInputModule} from 'ng2-tel-input';

Once done, we are ready to use this library.

How to use?

In order to use this directive, you need to add "ng2TelInput" directive with "[ng2TelInputOptions]" options to your text field. For example,

<input type="text"
  ng2TelInput
  [ng2TelInputOptions]="{initialCountry: 'in'}"
  (hasError)="hasError($event)"
  (ng2TelOutput)="getNumber($event)"
  (intlTelInputObject)="telInputObject($event)"
  (countryChange)="onCountryChange($event)" />

Note

(intlTelInputObject) returns intl-tel-input instance. By default this package get utils.js from below link:- https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/16.0.1/js/utils.js But you can also provide your utilsScript file by using below options:-

[ng2TelInputOptions]="{initialCountry: 'in', utilsScript: 'node_modules/intl-tel-input/build/js/utils.js'}"

How to use this instance?

You can use it perform any functionality that is available on intl-tel-input plugin. For example, in your component,

telInputObject(obj) {
    console.log(obj);
    obj.setCountry('in');
  }

ng2-tel-input's People

Contributors

gauravsoni119 avatar jhades avatar learath2 avatar leo6104 avatar matissjanis avatar thundersoul avatar timoweiss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ng2-tel-input's Issues

Ng2TelInputModule is not an NgModule

i add this line into my module into angular-cli project
import {Ng2TelInputModule} from 'ng2-intl-tel-input'
but i got error ng2-intl-tel-input not a module and i not found ng2-intl-tel-input dir into node_module

image

so, i tried to import import {Ng2TelInputModule} from 'ng2-tel-input' but got error.

please help me what i doing wrong.

Cannot determine the module for class Ng2TelInput

Hi, I'm using a Shared module to share some third party libraries, Ng2TelInputModule is one of them. But when I include ma shared module into an other module, when I build the module, I have this issue :

BUILD ERROR
: Cannot determine the module for class Ng2TelInput in .../node_modules/ng2-tel-input/src/ng2-tel-input.d.ts! Add Ng2TelInput to the NgModule to fix it.

I need to include Ng2TelInputModule in my module which include SharedModule which already include Ng2TelInputModule...

Is your library correctly exported ?

ng2-tel-input question

Thanks for a very good wrapper.
I have some questions.
How can i easily just got european countries in my list?
Is there any way to get the dialcode into the input field when i choose a country?

@NgModule annotation error in Angular 5

I am using Angular 5 and I have implemented this plugin.

when run the projects getting this type of error

Uncaught Error: Unexpected value 'Ng2TelInputModule' imported by the module 'AppModule'. Please add a @NgModule annotation.

Is there something I am missing?

Thank you in advance.

flag not changed automatically while edit form

i have used in reactive form method. code here
issue: when i open edit screen and patch a value into form. working fine. value displaying into input correctly but flag not changed. default flag appear. one i have change value then flag changed.
value after patch for ex. +917878747474

<input type="text"   formControlName="value_field"
 ng2TelInput
[ng2TelInputOptions]="{initialCountry: 'us'}"
(hasError)="hasError($event)"
(ng2TelOutput)="hasOutPut($event)"
(countryChange)="onCountryChange($event)"
maxlength="45"/>

please help me how to achieve this and fixed my problem. thanks in advance.

Is it possible to add mask in input

My client's requirement is to add mask by country. So user can't add wrong numbers.

I'd love to implement this feature.

Can anyone help me with this.

Uncaught TypeError: Cannot use 'in' operator to search for 'intlTelInputUtils' in undefined

vendor.js:209114 Uncaught TypeError: Cannot use 'in' operator to
search for 'intlTelInputUtils' in undefined
at m (vendor.js:209114)
at vendor.js:209579
at Object../node_modules/intl-tel-input/build/js/utils.js
(vendor.js:209583)
at webpack_require (runtime.js:85)
at Module../src/app/shared/directives/intl-tel-input.directive.ts
(main.js:11870)
at webpack_require (runtime.js:85)
at Module../src/app/shared/shared.module.ts (main.js:12967)
at webpack_require (runtime.js:85)
at Module../src/app/authentication/authentication.module.ts
(main.js:1078)
at webpack_require (runtime.js:85)

Peer dependencies warning

I am getting below peer dependencies warning. I am using this in angular 7.

After updating to Angular 8, it should not be giving warning in older angular versions.

npm WARN [email protected] requires a peer of @angular/core@^8.0.3 but none is installed. You must install peer dependencies yourself

package.json shuold be updated to remove these warnings.

Cannot use 'in' operator to search for 'intlTelInputUtils' in undefined in Angular 8

Getting below error after upgrading project to angular 8

Uncaught TypeError: Cannot use 'in' operator to search for 'intlTelInputUtils' in undefined
    at m (utils.js:1)
    at utils.js:443
    at Object../node_modules/ng2-tel-input/node_modules/intl-tel-input/build/js/utils.js (utils.js:447)
    at __webpack_require__ (bootstrap:84)
    at Module../node_modules/ng2-tel-input/src/ng2-tel-input.js (ng2-tel-input.js:1)
    at __webpack_require__ (bootstrap:84)
    at Module../node_modules/ng2-tel-input/src/ng2-tel-input.module.js (ng2-tel-input.module.js:1)
    at __webpack_require__ (bootstrap:84)
    at Module../node_modules/ng2-tel-input/ng2-tel-input.js (ng2-tel-input.js:1)
    at __webpack_require__ (bootstrap:84)

z-index of flags

Even though tried many times to reduce z-index of .selected-flag for example, and still getting exactly the same behaviour as on the image, i.e. whatever z-index will make in the .scss files (tried also in global) somehow it's bigger than my sidenav. Obviously tried to use even very large numbers for z-index of sidenav and same nothing changed. I'm using Angular Material, and tried to overwrite its styles as well, didn't work.

tel

Not able to disable placeholder

Hi I am using this plugin in my application and want to disable the default place holder in input field, how can I do that.
Thanks,

ERROR TypeError: window.intlTelInput is not a function

Hi,

unfortunately, ng2-tel-input is not working anymore after upgrading to the latest version 2.0.3 and intl-tel-input 16.0.2.

I'm getting the following error: ERROR TypeError: window.intlTelInput is not a function
at Ng2TelInput.push../node_modules/ng2-tel-input/src/ng2-tel-input.js.Ng2TelInput.ngOnInit (ng2-tel-input.js:41)

I imported the module, and added the scripts as mentioned in the docs.

Thanks
Gilles

How to use static methods like getCountryData?

I want to use getCountryData() static function mentioned in intl-tel-input documentation to set localized countries. Wondering how I can do it in this angular plugin. Did anyone try this?

Demo Request

Hi Gsoni,

Thanks For the package.Please add the Demo also.

Thanks
Ashish

Can't able to select flag

Can't able to get Country flag using country code like
[ng2TelInputOptions]="{initialCountry: US}" <========This is working Fine.
[ng2TelInputOptions]="{initialCountry: '1'}" <==== This is not.
Any solution.

After updating to latest version functions stopped working

I was using older version in my angular 7 project.

I just updated to latest versions & it's giving me errors in functions like setNumber.

this.objTelInput.intlTelInput("setNumber", this._contactNumber); This is how i was using before where this.objTelInput is a object received from intlTelInputObject event.

Now i am getting this error MaterialIntlTelInputComponent.html:5 ERROR TypeError: this.objTelInput.intlTelInput is not a function

Can anyone tell me what is changed in latest version? How to access methods like setNumber, getNumber?

window is undefined while doing server-side rendering

There are window object is being used in the project which is getting undefined while I am using Angular Universal to render the application from the server side.

Maybe if you add an additional check to those client-side object like window, local storage, document, location etc then it will not break from server-side rendering.

Clicking on the flag doesn't open the dropdown

I have this problem on Angular 4: when I click on the flag it doesn't open the country list. I think it opens and closes very fast. If I watch the element

    it gets the class "hide" immediately after removing it when I click.

    Is this just me doing something wrong or is it a common problem with intl-tel-input and Angular?

Implement using SystemJs

Hey, It's good library. But I am facing the error to integrate it with systemjs. Can you provide any solution for that it would we great help to me. Thanks

angular6 ionic4 - ng2TelInputOptions

Error: Uncaught (in promise): Error: Template parse errors: Can't bind to 'ng2TelInputOptions' since it isn't a known property of 'input'. (" <input type="text" ng2TelInput [ERROR ->][ng2TelInputOptions]="{initialCountry: 'in'}" (hasError)="hasError($event)" (ng2TelOutput)="getNu"):

will there be an update for new ionic/angular version?

AutoPlaceHolder with angular material mat-input not working

I'm trying to show the country placeholder example using matInput from angular material, but not works. I enabled autoPlaceholder = aggressive:
<input matInput type="text" ng2TelInput [ng2TelInputOptions]=" {'onlyCountries': ['pe', 'br'], 'separateDialCode': true, 'autoPlaceholder': 'aggressive'}" formControlName="tel" (hasError)="hasError($event)" (ng2TelOutput)="getNumber($event)" (intlTelInputObject)="telInputObject($event)" (countryChange)="onCountryChange($event)" >

ERROR TypeError: window.intlTelInput is not a function

Getting below error with "core-js": "^3.2.1"

ERROR TypeError: window.intlTelInput is not a function
    at Ng2TelInput.push../node_modules/ng2-tel-input/src/ng2-tel-input.js.Ng2TelInput.ngOnInit (ng2-tel-input.js:41)
    at checkAndUpdateDirectiveInline (core.js:31909)
    at checkAndUpdateNodeInline (core.js:44366)
    at checkAndUpdateNode (core.js:44305)
    at debugCheckAndUpdateNode (core.js:45327)
    at debugCheckDirectivesFn (core.js:45270)
    at Object.eval [as updateDirectives] (MaterialIntlTelInputComponent.html:5)
    at Object.debugUpdateDirectives [as updateDirectives] (core.js:45258)
    at checkAndUpdateView (core.js:44270)
    at callViewAction (core.js:44636)

How to integrate

I don't have idea how to integrate this into angular-cli project and how to include css file that doesn't exists

dropDown list scroll in ios

I have a weird issue , I used the component in my ionic3 app, the issue is that scrolling the dropdown list is working fine and smoothly in android , while in ios it is not smooth at all , seems like it is stuck and so heavy to move in real ios devices, any ideas

Get value with country code

I have input like below

<input type="tel" ng2TelInput (intlTelInputObject)="telInputObjectWork($event)" formControlName="WorkPhone" class="form-control" [ngClass]="{ 'is-invalid': submitted && f.WorkPhone.errors }" />

When in use intlTelInput("setNumber", "+917878747474"); it sets flag correctly.

But when i change value it's i am getting formatted value without country code (078 7874 7489) in WorkPhone.

i want "+917878747489" when i save in db.

How can i achieve this?

TypeError: this.ngTelInput.intlTelInput is not a function

Hi!
I am using you component for ionic development with ionic version 3.9.2 and angular version 5.2.10.
I imported this module in app.module.ts and when i try to use this component i would get following error.

ERROR Error: Uncaught (in promise): TypeError: this.ngTelInput.intlTelInput is not a function

Please also do tell me if i am missing any thing here. like importing any thing else or etc

Can you please check this.
Thanks

Issue while creating build

11:57:18] typescript error
Cannot write file '/Users/saad/Desktop/ttgapp/node_modules/intl-tel-input/build/js/intlTelInput.js' because
it would overwrite input file.

[11:57:18] typescript error
Cannot write file '/Users/saad/Desktop/ttgapp/node_modules/intl-tel-input/build/js/utils.js' because it
would overwrite input file.

[11:57:18] typescript error
Cannot write file '/Users/saad/Desktop/ttgapp/node_modules/intl-tel-input/index.js' because it would
overwrite input file.

[11:57:18] typescript error
Cannot write file '/Users/saad/Desktop/ttgapp/node_modules/jquery/dist/jquery.js' because it would overwrite
input file.

How dynamically change country flag ?

For example :
I have a list of users and any user has a phone number from different countries and when choosing a user I have to change the country flag.
Can I get advice on this ?
Thanks!

Angular 5 Error

When doing ng build on angular 5 I am getting the following error

ERROR in Error: Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 194:50 in the original .ts file), resolving symbol NgModule in /usr/src/app/node_modules/ng2-tel-input/node_modules/@angular/core/core.d.ts, resolving symbol Ng2TelInputModule in /usr/src/app/node_modules/ng2-tel-input/src/ng2-tel-input.module.d.ts, resolving symbol Ng2TelInputModule in /usr/src/app/node_modules/ng2-tel-input/src/ng2-tel-input.module.d.ts

Have you successfully used this library in angular 5.x ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.