Giter VIP home page Giter VIP logo

angular-international-number's Introduction

Intro

This library is for International Phone Number Validation for Angular using Directive. It supports both Template driven and Reactive Forms.

libphonenumber-js is used for the Phone Number validation.

Demo

Usage

  1. npm i ngx-international-number

  2. Add InternationalPhoneModule import to your NgModule (where the directive is used) like this:

    import { NgxInternationalNumberModule } from "ngx-international-number";
    
    @NgModule({
      imports: [NgxInternationalNumberModule],
    })
    export class AuthModule {}
  3. Add the Directive to you Phone Number Input like this:

    <input
     type="tel"
     formControlName="phoneNumber"
     international-number
     defaultCountry="PK"
     (countrySelected)="countryChanged($event)"/>

Inputs

Name Type Default Description
searchPlaceHolder string? null The Placeholder for the search input
defaultCountry string? null Alpha 2 Country Code
hue string? 212 HSL color Hue value for customizing theme
customScrollbar boolean? true Use false to disable theming for scrollbar

Outputs

Name Parameters Description
countrySelected country: Country Emits whenever there is a change in country selected including the default country
dropdownOpened didOpen: boolean Emits whenever dropdown is toggled

Styling

  • dropdown-open class is added on the root element of country select when dropdown is open for custom styling

Sources

Flags used are from this Package

The Countries Data was copied form this Github Repo

angular-international-number's People

Contributors

all2pie avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

klocus

angular-international-number's Issues

Add state class for active dropdown

Currently missing is any class that marks the state of the dropdown (whether it is open or not). This makes it impossible for me to set a custom arrow icon.

The drop-down lang list takes a long time to open

As in the title: Opening the drop-down lang list takes a long time. Maybe the cause is using *ngIf instead of a class that would hide and show the dropdown menu?

Currently *ngIf removes all HTML code from the document structure, making the drop-down render again every time you click on the arrow. It seems to me that hiding this list using CSS would be more efficient, such as by display: none and display: block.

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.