[ Web Proxy ]
URL:
Viewing: https://angular.dev/api/forms/SelectMultipleControlValueAccessor [Back]  [Original]

SelectMultipleControlValueAccessor Angular Skip to main content
menu
close
more_horiz
menuAPI
@angular/forms

SelectMultipleControlValueAccessor

directive
stable

The ControlValueAccessor for writing multi-select control values and listening to multi-select control changes. The value accessor is used by the FormControlDirective, FormControlName, and NgModel directives.

SelectControlValueAccessor

On this page

    arrow_upward_alt Back to the top

    API

        
          class SelectMultipleControlValueAccessor extends BuiltInControlValueAccessor implements ControlValueAccessor {  @Input() set compareWith(value: (o1: any, o2: any) => boolean);}
        
        

    compareWith

    (o1: any, o2: any) => boolean

    Tracks the option comparison algorithm for tracking identities when checking for changes.

    Description

    The ControlValueAccessor for writing multi-select control values and listening to multi-select control changes. The value accessor is used by the FormControlDirective, FormControlName, and NgModel directives.

    Exported by

    Usage Notes

    Using a multi-select control

    The follow example shows you how to use a multi-select control with a reactive form.

    const countryControl = new FormControl();
    <select multiple name="countries" [formControl]="countryControl">
      @for(country of countries; track $index) {
         <option [ngValue]="country">{{ country.name }}</option>
      }
    </select>

    Customizing option selection

    To customize the default option comparison algorithm, <select> supports compareWith input. See the SelectControlValueAccessor for usage.

    Jump to details

    Web Proxy Viewer  |  New URL  |  Original Page