NG Kit

Country select

A single-select over object options with a fully custom option row. getOptionLabel maps each country to its display string, while an *ngOption template renders the flag emoji, country name and dial code.

Usage

Import AutocompleteComponent and configure it with the inputs below. The full runnable source is on the Examples tab.

html
<autocomplete
  [options]="countries"
  [(value)]="value"
  [getOptionLabel]="getOptionLabel"
  label="Country">
  <div *ngOption="let country">
    {{ country.label }} (+{{ country.phone }})
  </div>
</autocomplete>

API

This example demonstrates the inputs below. See the Autocomplete introduction for the complete API — every input, output, content template and filter helper.

Inputs

NameTypeDefaultDescription
optionsreadonly T[]— (required)The list of options shown in the panel.
valueT | T[] | nullnullTwo-way selected value (model). An array when multiple.
getOptionLabel(option: T) => stringoption.label ?? String(option)Maps an option to its display string.
labelstring | nullnullField label (mat-label).

Content templates

DirectiveMUI equivalentPurpose
*ngOptionrenderOptionCustom option row. Context: $implicit (option), option, highlighted, selected, query.