Class Overview
class SelectMultipleControlValueAccessor implements ControlValueAccessor {
constructor
(_renderer: Renderer, _elementRef: ElementRef)
value
: any
onChange
: (_: any) => {}
onTouched
: () => {}
compareWith
writeValue
(value: any) : void
registerOnChange
(fn: (value: any) => any) : void
registerOnTouched
(fn: () => any) : void
setDisabledState
(isDisabled: boolean) : void
}
Selectors
select[multiple][formControlName]
select[multiple][formControl]
select[multiple][ngModel]
Class Description
The accessor for writing a value and listening to changes on a select element.
Caveat: Options selection
Angular uses object identity to select options. It's possible for the identities of items to change while the data does not. This can happen, for example, if the items are produced from an RPC to the server, and that RPC is re-run. Even if the data hasn't changed, the second response will produce objects with different identities.
To customize the default option comparison algorithm, <select multiple>
supports compareWith
input. compareWith
takes a function which has two arguments: option1
and option2
.
If compareWith
is given, Angular selects options by the return value of the function.
Syntax
Class Details
exported from forms/index, defined in forms/src/directives/select_multiple_control_value_accessor.ts