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');
  }

N|Solid

ng2-tel-input's People

Contributors

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

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.