Giter Site home page Giter Site logo

nivalamata / ngx-international-phone-number Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nikhiln/ngx-international-phone-number

0.0 1.0 0.0 2.22 MB

A simple international telephone number input for Angular

License: MIT License

JavaScript 18.58% TypeScript 76.86% HTML 2.57% CSS 1.99%

ngx-international-phone-number's Introduction

ngx-international-phone-number

A simple international telephone number input. Allows you to create a phone number field with country dropdown.

This is re-written version (with enhancement) of ng4-intl-phone. So credit should go to kondi0.

Installation

To install this library, run:

$ npm install ngx-international-phone-number --save

Consuming your library

Once you have installed it you can import InternationalPhoneNumberModule from ngx-international-phone-number in any application module. E.g.

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';

// Import your library
import { InternationalPhoneNumberModule } from 'ngx-international-phone-number';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,

    // InternationalPhoneNumberModule module
    InternationalPhoneNumberModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Once it is imported, you can use international-phone-number:

<!-- app.component.html -->
<form name="sample-form" (ngSubmit)="submit()" #f="ngForm">
 <international-phone-number [(ngModel)]="model.phone_number" placeholder="Enter phone number" [maxlength]="20" [defaultCountry]="'in'" [required]="true" #phoneNumber="ngModel" name="phone_number" [allowedCountries]="['in', 'ca', 'us']"></international-phone-number>

  <div *ngIf="f.submitted && !phoneNumber.valid" class="help-block">Phone number is required and should be valid</div>
  <button type="submit">Submit</button>
</form>

Attributes/Options:

   defaultCountryCode : An ISO 3166 country code can be provided to set default country selected.
   placeholder: A placeholder text which would be displayed in input widget
   required: Indicates whether it's required or not
   onlyNumber: Indicates whether the user can type only numbers or not in the input field. It defaults to true.
   allowDropdown: Indicates whether to allow selecting country from dropdown
   allowedCountries: A list of countries (iso codes) that would get display in country dropdown. E.g. [allowedCountries]="['in', 'ca', 'us']" would only show Canada, India and US. If not provided, all the countries would get displayed.

Troubleshooting:

If you are getting error "Can't resolve 'google-libphonenumber'" while building with aot, try to install google-libphonenumber. Run npm install [email protected] --save

Authors

* Original Author: kondi0
* Author: nikhiln 

License

MIT

ngx-international-phone-number's People

Contributors

aalves-quantumit avatar arnex93 avatar dependabot[bot] avatar nikhiln avatar vshkotin avatar wverne avatar

Watchers

 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.