Skip to content

Forms

ng-select supports Signal Forms, Reactive Forms and Template-driven Forms through the same control value accessor.

Import FormField from @angular/forms/signals and bind a field from the tree returned by form(). FormsModule is not required for this integration.

import { signal } from '@angular/core';
import { form, FormField, required } from '@angular/forms/signals';
import { NgSelectComponent } from '@ng-select/ng-select';
@Component({
imports: [FormField, NgSelectComponent],
})
export class CityEditor {
readonly model = signal({ cityId: null as number | null });
readonly cityForm = form(this.model, (path) => required(path.cityId));
}
<ng-select [items]="cities" bindLabel="name" bindValue="id" [formField]="cityForm.cityId" />

The example also covers initial values before async items arrive, multiple selection, validation, disabled state, and recreating the control with @if.

Signal Forms keeps validation state on the field tree and does not add Angular's legacy ng-valid, ng-invalid, ng-touched, and ng-dirty classes unless configured. Applications that use those classes with an ng-select theme can enable the compatibility preset:

import { provideSignalFormsConfig } from '@angular/forms/signals';
import { NG_STATUS_CLASSES } from '@angular/forms/signals/compat';
bootstrapApplication(AppComponent, {
providers: [provideSignalFormsConfig({ classes: NG_STATUS_CLASSES })],
});

Import ReactiveFormsModule and bind ng-select with formControl, formControlName, or a containing FormGroup.

Import FormsModule, bind with [(ngModel)], and provide name when the control is inside a form.

Inputs used by the examples on this page:

Input Type Default Description
[items] Array<any> [] Items array
bindLabel string label Object property to use for label. Default label
bindValue string - Object property to use for selected model. By default binds to whole object.
[multiple] boolean false Allows to select multiple items.
[clearable] boolean true Allow to clear selected value. Default true
[readonly] boolean false Set ng-select as readonly.
[searchable] boolean true Allow to search for value. Default true
placeholder string - Placeholder text.
labelForId string - Id to associate control with label.
appearance string underline Allows to select dropdown appearance. Set to outline or fill for Material form-field styles (applies only to Material theme)
dropdownPosition bottom | top | left | right | auto auto Set the dropdown position on open
clearAllText string Clear all Set custom text for clear all icon title
[selectOnTab] boolean false Select marked dropdown item using tab. Default false
[virtualScroll] boolean false Enable virtual scroll for better performance when rendering a lot of data

Outputs used by the examples on this page:

Output Description
(change) Fired on selection change. Outputs the selected item (an array when [multiple]="true") as the whole item object, not the bindValue-projected model value

See the NgSelectComponent API reference for the complete list of inputs and outputs.