2.0.1 • Published 1 year ago
ngx-international-number v2.0.1
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-numberAdd InternationalPhoneModule import to your NgModule like this:
import { NgxInternationalNumberModule } from "ngx-international-number"; @NgModule({ imports: [NgxInternationalNumberModule], }) export class MainModule {}Add the
international-numberdirective 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-selectclass is used for the main wrapper of select componentdropdown-openclass is added on the main wrapper of component when dropdown is opencountry-select-btnclass is used for the button that opens the dropdown and is added at start of input fielddropdownclass is used for the dropdown