2.0.1 • Published 1 year ago

ngx-international-number v2.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Intro

This library is for International Phone Number Validation for Angular using Directive. It supports both Template driven and Reactive Forms. You can use your existing inputs with custom styling and just add the international-number directive to add phone number validation.

libphonenumber-js is used for the Phone Number validation.

Demo

Usage

  1. npm i ngx-international-number

  2. Add InternationalPhoneModule import to your NgModule like this:

    import { NgxInternationalNumberModule } from "ngx-international-number";
    
    @NgModule({
      imports: [NgxInternationalNumberModule],
    })
    export class MainModule {}
  3. Add the international-number directive to you phone number input like this:

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

Inputs

NameTypeDefaultDescription
searchPlaceHolderstring?nullThe Placeholder for the search input
defaultCountrystring?nullAlpha 2 Country Code
huestring?212HSL color Hue value for customizing theme
customScrollbarboolean?trueUse false to disable theming for scrollbar

Outputs

NameParametersDescription
countrySelectedcountry: CountryEmits whenever there is a change in country selected including the default country
dropdownOpeneddidOpen: booleanEmits whenever dropdown is toggled

Styling

  • country-select class is used for the main wrapper of select component
  • dropdown-open class is added on the main wrapper of component when dropdown is open
  • country-select-btn class is used for the button that opens the dropdown and is added at start of input field
  • dropdown class is used for the dropdown

Sources

  • Flags used are from here
  • Countries data was sourced form this repo
1.1.1

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.1.0

3 years ago

1.0.3

3 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.9.0

4 years ago

0.3.0

4 years ago

0.2.0

4 years ago

0.8.0

4 years ago

0.5.0

4 years ago

0.4.0

4 years ago

0.7.0

4 years ago

0.6.0

4 years ago

0.1.0

4 years ago

0.0.1

4 years ago