Listen to this story
Full-time Software Developer based in Vienna. Doing great things with Angular!
The code in this story is for educational purposes. The readers are solely responsible for whatever they build with it.
Walkthroughs, tutorials, guides, and tips. This story will teach you how to do something new or how to do something better.
Hey everyone! I'm super excited to introduce ng-country-select – a high-performance, multilingual country autocomplete built on Angular and Angular Material. If you’ve ever needed a quick and elegant way to select countries in your apps (complete with flags, codes, and translations), look no further!
https://github.com/wlucha/ng-country-select
Try it out in our Live Demo and see it in action!
Angular Version |
Supported? |
---|---|
|
✅ Yes |
|
✅ Yes |
|
✅ Yes |
|
✅ Yes |
npm install --save @angular/material @angular/cdk @angular/animations @wlucha/ng-country-select
import { CountrySelectComponent } from '@wlucha/ng-country-select';
@NgModule({
imports: [
CountrySelectComponent,
// ... other imports
]
})
<ng-country-select
[lang]="'en'"
(countrySelected)="handleSelection($event)"
></ng-country-select>
Parameter |
Type |
Default |
Description |
---|---|---|---|
|
`Country |
null` |
|
|
`Country |
null` |
- |
|
|
|
Language for displaying country names (e.g., |
|
|
|
If |
|
|
|
Placeholder text for the input field |
|
|
|
Debounce time in milliseconds for the search input |
|
|
|
Disables the component if |
|
`'fill' |
'outline'` |
|
|
|
|
Marks the field as required if |
|
|
|
If |
|
|
|
Angular Material color palette to use ( |
Event |
Output |
Description |
---|---|---|
|
|
Full country object on selection |
|
|
Live search term updates |
|
|
When dropdown closes |
<ng-country-select
[lang]="'en'"
[searchAllLanguages]="true"
[showCodes]="true"
[debounceTime]="200"
[appearance]="'outline'"
[placeholder]="'Search country'"
(countrySelected)="onCountrySelect($event)"
(inputChanged)="trackSearchTerm($event)"
></ng-country-select>
Love this component? Here's how you can help:
# Your star fuels development! ⭐
# Clone and explore:
git clone https://github.com/wlucha/ng-country-select.git