/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { ElementRef, OnDestroy, Renderer2 } from '@angular/core'; import { BuiltInControlValueAccessor, ControlValueAccessor } from './control_value_accessor'; import * as i0 from "@angular/core"; /** * @description * The `ControlValueAccessor` for writing select control values and listening to select control * changes. The value accessor is used by the `FormControlDirective`, `FormControlName`, and * `NgModel` directives. * * @usageNotes * * ### Using select controls in a reactive form * * The following examples show how to use a select control in a reactive form. * * {@example forms/ts/reactiveSelectControl/reactive_select_control_example.ts region='Component'} * * ### Using select controls in a template-driven form * * To use a select in a template-driven form, simply add an `ngModel` and a `name` * attribute to the main `` supports `compareWith` input. * `compareWith` takes a **function** which has two arguments: `option1` and `option2`. * If `compareWith` is given, Angular selects option by the return value of the function. * * ```ts * const selectedCountriesControl = new FormControl(); * ``` * * ``` * * * compareFn(c1: Country, c2: Country): boolean { * return c1 && c2 ? c1.id === c2.id : c1 === c2; * } * ``` * * **Note:** We listen to the 'change' event because 'input' events aren't fired * for selects in IE, see: * https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/input_event#browser_compatibility * * @ngModule ReactiveFormsModule * @ngModule FormsModule * @publicApi */ export declare class SelectControlValueAccessor extends BuiltInControlValueAccessor implements ControlValueAccessor { /** @nodoc */ value: any; /** @internal */ _optionMap: Map; /** @internal */ _idCounter: number; /** * @description * Tracks the option comparison algorithm for tracking identities when * checking for changes. */ set compareWith(fn: (o1: any, o2: any) => boolean); private _compareWith; /** * Sets the "value" property on the select element. * @nodoc */ writeValue(value: any): void; /** * Registers a function called when the control value changes. * @nodoc */ registerOnChange(fn: (value: any) => any): void; /** @internal */ _registerOption(): string; /** @internal */ _getOptionId(value: any): string | null; /** @internal */ _getOptionValue(valueString: string): any; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } /** * @description * Marks `