Installations
npm install angular-phone-number
Developer Guide
Typescript
No
Module System
ESM
Node Version
18.20.2
NPM Version
10.5.0
Releases
Unable to fetch releases
Love this project? Help keep it running — sponsor us today! 🚀
Download Statistics
Total Downloads
939
Last Day
42
Last Week
939
Last Month
939
Last Year
939
Bundle Size
202.61 kB
Minified
54.78 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.0.15
Package Id
angular-phone-number@1.0.15
Unpacked Size
1.05 MB
Size
270.58 kB
File Count
20
NPM Version
10.5.0
Node Version
18.20.2
Publised On
05 Feb 2025
Total Downloads
Cumulative downloads
Total Downloads
939
Last day
0%
42
Compared to previous day
Last week
0%
939
Compared to previous week
Last month
0%
939
Compared to previous month
Last year
0%
939
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Peer Dependencies
2
Angular Phone Number
Installation
To install the Angular Phone Number package, run the following command:
1npm i angular-phone-number
This package implements country-specific validations using libphonenumber-js.
Install the required dependencies:
1npm i libphonenumber-js -D
Usage
Import the AngularPhoneNumber
module into your module file:
1import { AngularPhoneNumber } from 'angular-phone-number';
Add AngularPhoneNumber
to your module imports:
1@NgModule({ 2 imports: [AngularPhoneNumber] 3}) 4export 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:
1@Component({ 2 selector: 'app-root', 3 template: ` 4 <form [formGroup]="myForm"> 5 <angular-phone-number 6 formControlName="phoneNumber" 7 [defaultCountry]="'LK'" 8 [preferredCountries]="['LK', 'IN', 'GB']" 9 [error]="myForm.get('phoneNumber')?.touched && myForm.get('phoneNumber')?.invalid" 10 (countryChanged)="onCountryChanged($event)" 11 (inputChanged)="onInputChanged($event)" 12 ></angular-phone-number> 13 </form> 14 `, 15 styles: [] 16}) 17export class AppComponent { 18 myForm: FormGroup = new FormGroup({ 19 phoneNumber: new FormControl(''), 20 }); 21 22 onCountryChanged(event: any) { 23 console.log('Country changed:', event); 24 } 25 26 onInputChanged(event: any) { 27 console.log('Input changed:', event); 28 } 29}
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. |
(countryChanged) | EventEmitter | null | Emits an event when the country is changed. |
(inputChanged) | EventEmitter | null | Emits an event when the input is changed. |
Country List
Below is the list of supported countries and their codes:
1{ 2 "AF": "Afghanistan", 3 "AX": "Aland Islands", 4 "AL": "Albania", 5 "DZ": "Algeria", 6 "AS": "American Samoa", 7 "AD": "Andorra", 8 "AO": "Angola", 9 "AI": "Anguilla", 10 "AQ": "Antarctica", 11 "AG": "Antigua and Barbuda", 12 "AR": "Argentina", 13 "AM": "Armenia", 14 "AW": "Aruba", 15 "AC": "Ascension Island", 16 "AU": "Australia", 17 "AT": "Austria", 18 "AZ": "Azerbaijan", 19 "BS": "Bahamas", 20 "BH": "Bahrain", 21 "BD": "Bangladesh", 22 "BB": "Barbados", 23 "BY": "Belarus", 24 "BE": "Belgium", 25 "BZ": "Belize", 26 "BJ": "Benin", 27 "BM": "Bermuda", 28 "BT": "Bhutan", 29 "BO": "Bolivia", 30 "BA": "Bosnia and Herzegovina", 31 "BW": "Botswana", 32 "BR": "Brazil", 33 "IO": "British Indian Ocean Territory", 34 "BN": "Brunei Darussalam", 35 "BG": "Bulgaria", 36 "BF": "Burkina Faso", 37 "BI": "Burundi", 38 "KH": "Cambodia", 39 "CM": "Cameroon", 40 "CA": "Canada", 41 "CV": "Cape Verde", 42 "KY": "Cayman Islands", 43 "CF": "Central African Republic", 44 "TD": "Chad", 45 "CL": "Chile", 46 "CN": "China", 47 "CX": "Christmas Island", 48 "CC": "Cocos (Keeling) Islands", 49 "CO": "Colombia", 50 "KM": "Comoros", 51 "CG": "Congo", 52 "CK": "Cook Islands", 53 "CR": "Costa Rica", 54 "CI": "Cote d'Ivoire", 55 "HR": "Croatia", 56 "CU": "Cuba", 57 "CY": "Cyprus", 58 "CZ": "Czech Republic", 59 "CD": "Democratic Republic of the Congo", 60 "DK": "Denmark", 61 "DJ": "Djibouti", 62 "DM": "Dominica", 63 "DO": "Dominican Republic", 64 "EC": "Ecuador", 65 "EG": "Egypt", 66 "SV": "El Salvador", 67 "GQ": "Equatorial Guinea", 68 "ER": "Eritrea", 69 "EE": "Estonia", 70 "SZ": "Eswatini", 71 "ET": "Ethiopia", 72 "FK": "Falkland Islands (Malvinas)", 73 "FO": "Faroe Islands", 74 "FJ": "Fiji", 75 "FI": "Finland", 76 "FR": "France", 77 "GF": "French Guiana", 78 "PF": "French Polynesia", 79 "GA": "Gabon", 80 "GM": "Gambia", 81 "GE": "Georgia", 82 "DE": "Germany", 83 "GH": "Ghana", 84 "GI": "Gibraltar", 85 "GR": "Greece", 86 "GL": "Greenland", 87 "GD": "Grenada", 88 "GP": "Guadeloupe", 89 "GU": "Guam", 90 "GT": "Guatemala", 91 "GG": "Guernsey", 92 "GN": "Guinea", 93 "GW": "Guinea-Bissau", 94 "GY": "Guyana", 95 "HT": "Haiti", 96 "VA": "Holy See (Vatican City State)", 97 "HN": "Honduras", 98 "HK": "Hong Kong", 99 "HU": "Hungary", 100 "IS": "Iceland", 101 "IN": "India", 102 "ID": "Indonesia", 103 "IR": "Iran", 104 "IQ": "Iraq", 105 "IE": "Ireland", 106 "IM": "Isle of Man", 107 "IL": "Israel", 108 "IT": "Italy", 109 "JM": "Jamaica", 110 "JP": "Japan", 111 "JE": "Jersey", 112 "JO": "Jordan", 113 "KZ": "Kazakhstan", 114 "KE": "Kenya", 115 "KI": "Kiribati", 116 "KP": "Korea, Democratic People's Republic of Korea", 117 "KR": "Korea, Republic of South Korea", 118 "XK": "Kosovo", 119 "KW": "Kuwait", 120 "KG": "Kyrgyzstan", 121 "LA": "Laos", 122 "LV": "Latvia", 123 "LB": "Lebanon", 124 "LS": "Lesotho", 125 "LR": "Liberia", 126 "LY": "Libya", 127 "LI": "Liechtenstein", 128 "LT": "Lithuania", 129 "LU": "Luxembourg", 130 "MO": "Macau", 131 "MG": "Madagascar", 132 "MW": "Malawi", 133 "MY": "Malaysia", 134 "MV": "Maldives", 135 "ML": "Mali", 136 "MT": "Malta", 137 "MH": "Marshall Islands", 138 "MQ": "Martinique", 139 "MR": "Mauritania", 140 "MU": "Mauritius", 141 "YT": "Mayotte", 142 "MX": "Mexico", 143 "FM": "Micronesia, Federated States of Micronesia", 144 "MD": "Moldova", 145 "MC": "Monaco", 146 "MN": "Mongolia", 147 "ME": "Montenegro", 148 "MS": "Montserrat", 149 "MA": "Morocco", 150 "MZ": "Mozambique", 151 "MM": "Myanmar", 152 "NA": "Namibia", 153 "NR": "Nauru", 154 "NP": "Nepal", 155 "NL": "Netherlands", 156 "NC": "New Caledonia", 157 "NZ": "New Zealand", 158 "NI": "Nicaragua", 159 "NE": "Niger", 160 "NG": "Nigeria", 161 "NU": "Niue", 162 "NF": "Norfolk Island", 163 "MK": "North Macedonia", 164 "MP": "Northern Mariana Islands", 165 "NO": "Norway", 166 "OM": "Oman", 167 "PK": "Pakistan", 168 "PW": "Palau", 169 "PS": "Palestine", 170 "PA": "Panama", 171 "PG": "Papua New Guinea", 172 "PY": "Paraguay", 173 "PE": "Peru", 174 "PH": "Philippines", 175 "PN": "Pitcairn", 176 "PL": "Poland", 177 "PT": "Portugal", 178 "PR": "Puerto Rico", 179 "QA": "Qatar", 180 "RE": "Reunion", 181 "RO": "Romania", 182 "RU": "Russia", 183 "RW": "Rwanda", 184 "BL": "Saint Barthelemy", 185 "SH": "Saint Helena, Ascension and Tristan Da Cunha", 186 "KN": "Saint Kitts and Nevis", 187 "LC": "Saint Lucia", 188 "MF": "Saint Martin", 189 "PM": "Saint Pierre and Miquelon", 190 "VC": "Saint Vincent and the Grenadines", 191 "WS": "Samoa", 192 "SM": "San Marino", 193 "ST": "Sao Tome and Principe", 194 "SA": "Saudi Arabia", 195 "SN": "Senegal", 196 "RS": "Serbia", 197 "SC": "Seychelles", 198 "SL": "Sierra Leone", 199 "SG": "Singapore", 200 "SX": "Sint Maarten", 201 "SK": "Slovakia", 202 "SI": "Slovenia", 203 "SB": "Solomon Islands", 204 "SO": "Somalia", 205 "ZA": "South Africa", 206 "GS": "South Georgia and the South Sandwich Islands", 207 "SS": "South Sudan", 208 "ES": "Spain", 209 "LK": "Sri Lanka", 210 "SD": "Sudan", 211 "SR": "Suriname", 212 "SJ": "Svalbard and Jan Mayen", 213 "SE": "Sweden", 214 "CH": "Switzerland", 215 "SY": "Syrian Arab Republic", 216 "TW": "Taiwan", 217 "TJ": "Tajikistan", 218 "TZ": "Tanzania, United Republic of Tanzania", 219 "TH": "Thailand", 220 "TL": "Timor-Leste", 221 "TG": "Togo", 222 "TK": "Tokelau", 223 "TO": "Tonga", 224 "TT": "Trinidad and Tobago", 225 "TN": "Tunisia", 226 "TR": "Turkey", 227 "TM": "Turkmenistan", 228 "TC": "Turks and Caicos Islands", 229 "TV": "Tuvalu", 230 "UG": "Uganda", 231 "UA": "Ukraine", 232 "AE": "United Arab Emirates", 233 "GB": "United Kingdom", 234 "US": "United States", 235 "UY": "Uruguay", 236 "UZ": "Uzbekistan", 237 "VU": "Vanuatu", 238 "VE": "Venezuela, Bolivarian Republic of Venezuela", 239 "VN": "Vietnam", 240 "VG": "Virgin Islands, British", 241 "VI": "Virgin Islands, U.S.", 242 "WF": "Wallis and Futuna", 243 "YE": "Yemen", 244 "ZM": "Zambia", 245 "ZW": "Zimbabwe" 246}
No vulnerabilities found.
No security vulnerabilities found.
Other packages similar to angular-phone-number
angular-phone-number-input
Angular Phone Number Input
angular-phone-helper
Useful tool for piping and detecting phone format - 188 countries + International format
ngx-intl-phone-number
International phone number validation for Angular using directive.
angular-intl-phone
A Angular(6+) Intl Phone Input having country dropdown with phone validation supports