◐ Shell
reader mode source ↗
Skip to main content
menu
menuAPI
  • arrow_back API Reference
    • Overview
    • @angular/animations
    • @angular/animations/browser
    • @angular/animations/browser/testing
    • @angular/aria/accordion
    • @angular/aria/combobox
    • @angular/aria/grid
    • @angular/aria/listbox
    • @angular/aria/menu
    • @angular/aria/tabs
    • @angular/aria/toolbar
    • @angular/aria/tree
    • @angular/cdk/drag-drop
    • @angular/cdk/testing
    • @angular/cdk/testing/protractor
    • @angular/cdk/testing/selenium-webdriver
    • @angular/cdk/testing/testbed
    • @angular/common
    • @angular/common/http
    • @angular/common/http/testing
    • @angular/common/testing
    • @angular/common/upgrade
    • @angular/core
    • @angular/core/rxjs-interop
    • @angular/core/testing
    • @angular/elements
    • @angular/forms
    • @angular/forms/signals
    • @angular/forms/signals/compat
    • @angular/localize
    • @angular/localize/init
    • @angular/platform-browser
    • @angular/platform-browser-dynamic
    • @angular/platform-browser-dynamic/testing
    • @angular/platform-browser/animations
    • @angular/platform-browser/animations/async
    • @angular/platform-browser/testing
    • @angular/platform-server
    • @angular/platform-server/testing
    • @angular/router
    • @angular/router/testing
    • @angular/router/upgrade
    • @angular/service-worker
    • @angular/ssr
    • @angular/ssr/node
    • @angular/upgrade
    • @angular/upgrade/static
    • @angular/upgrade/static/testing
    • window.ng globals
@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.

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