ngx-international-number
v2.0.1
Published
International Phone Number Validation for Angular using Directive
Downloads
231
Maintainers
Readme
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.
Usage
npm i ngx-international-number
Add InternationalPhoneModule import to your NgModule like this:
import { NgxInternationalNumberModule } from "ngx-international-number"; @NgModule({ imports: [NgxInternationalNumberModule], }) export class MainModule {}
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
| 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
country-select
class is used for the main wrapper of select componentdropdown-open
class is added on the main wrapper of component when dropdown is opencountry-select-btn
class is used for the button that opens the dropdown and is added at start of input fielddropdown
class is used for the dropdown