npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

angular-phone-number

v1.1.3

Published

A comprehensive international phone number input component for Angular applications with country selection, validation, and formatting.

Readme

Angular Phone Number

A comprehensive international phone number input component for Angular applications with country selection, validation, and formatting.

Installation

To install the Angular Phone Number package, run the following command:

npm i angular-phone-number

This package implements country-specific validations using libphonenumber-js.

Install the required dependencies:

npm i libphonenumber-js -D

Flag Assets Setup

Important: To display country flags correctly, you need to copy the flag assets to your project:

  1. Copy the flag assets from the package to your project:

    cp -r node_modules/angular-phone-number/assets/flags src/assets
  2. Ensure your Angular project is configured to include the assets folder in your angular.json file:

    "assets": [
      "src/favicon.ico",
      "src/assets"
    ],

Usage

Import the AngularPhoneNumber module into your module file:

import { AngularPhoneNumber } from 'angular-phone-number';

Add AngularPhoneNumber to your module imports:

@NgModule({
  imports: [AngularPhoneNumber]
})
export class AppModule { }

This package displays country names in both Arabic and English.

Example

Here is an example of how to use the Angular Phone Number component in your application:

@Component({
  selector: 'app-root',
  template: `
    <form [formGroup]="myForm">
      <angular-phone-number
        formControlName="phoneNumber"
        [defaultCountry]="'LK'"
        [preferredCountries]="['LK', 'IN', 'GB']"
        [error]="myForm.get('phoneNumber')?.touched && myForm.get('phoneNumber')?.invalid"
        (countryChanged)="onCountryChanged($event)"
        (inputChanged)="onInputChanged($event)"
      ></angular-phone-number>
    </form>
  `,
  styles: []
})
export class AppComponent {
  myForm: FormGroup = new FormGroup({
    phoneNumber: new FormControl(''),
  });
  
  onCountryChanged(event: any) {
    console.log('Country changed:', event);
  }

  onInputChanged(event: any) {
    console.log('Input changed:', event);
  }
}

Options

The following options are available for the Angular Phone Number component:

| Option | Type | Default | Description | | -------------------- | ------------- | ----------------- | --------------------------------------------- | | defaultCountry | string | null | Set the default country from the list. | | preferredCountries | string[] | All countries | List of country codes to be displayed. | | error | boolean | false | Display the error status in the input box. | | border | boolean | true | Display borders around the input box. | | language | ar en | en | Change country name based on language. | | mode | ar all | all | When set to 'ar', prioritizes Arabic countries in the list. | | priorityCountries | string[] | [] | List of country codes to display first in the dropdown. | | (countryChanged) | EventEmitter| null | Emits an event when the country is changed. | | (inputChanged) | EventEmitter| null | Emits an event when the input is changed. |

Country Ordering Features

Arabic Countries Mode

The mode input allows you to prioritize Arabic countries in the dropdown list:

<angular-phone-number 
  [mode]="'ar'" 
  [defaultCountry]="'SA'">
</angular-phone-number>

When mode="ar" is set, all Arabic countries will be displayed at the top of the dropdown list.

Priority Countries

The priorityCountries input allows you to specify which countries should appear first in the dropdown:

<angular-phone-number 
  [priorityCountries]="['US', 'CA', 'GB']" 
  [defaultCountry]="'US'">
</angular-phone-number>

This will display USA, Canada, and Great Britain at the top of the list, in that exact order.

Combining Ordering Features

You can use both features together:

<angular-phone-number 
  [mode]="'ar'" 
  [priorityCountries]="['EG', 'SA', 'AE']" 
  [defaultCountry]="'EG'">
</angular-phone-number>

Note: When both features are used, priorityCountries takes precedence over the mode setting.

Important Notes

  • preferredCountries filters the dropdown to only show the specified countries.
  • priorityCountries shows the specified countries first, followed by all other countries.

Country List

The component supports a comprehensive list of countries with their respective codes. Here are some examples:

  • US: United States
  • GB: United Kingdom
  • IN: India
  • LK: Sri Lanka
  • CA: Canada
  • AU: Australia

The full list includes over 200 countries and territories with their ISO codes.