UNPKG

@ionic/angular

Version:

Angular specific wrappers for @ionic/core

44 lines 2.54 kB
import { Directive, HostListener } from '@angular/core'; import { NG_VALUE_ACCESSOR } from '@angular/forms'; import { ValueAccessor } from '@ionic/angular/common'; import * as i0 from "@angular/core"; export class SelectValueAccessorDirective extends ValueAccessor { constructor(injector, el) { super(injector, el); } // Bind `$event` and cast `.target` in the body rather than `['$event.target']`: // this directive's multi-element selector makes Angular 22's stricter host-binding // type checking infer `$event` as the DOM `Event` (target: `EventTarget | null`), // not the concrete element. The single-element standalone CVAs keep `['$event.target']`. _handleChangeEvent(ev) { const el = ev.target; this.handleValueChange(el, el.value); } /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: SelectValueAccessorDirective, deps: [{ token: i0.Injector }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.0", type: SelectValueAccessorDirective, isStandalone: false, selector: "ion-select, ion-radio-group, ion-segment, ion-datetime", host: { listeners: { "ionChange": "_handleChangeEvent($event)" } }, providers: [ { provide: NG_VALUE_ACCESSOR, useExisting: SelectValueAccessorDirective, multi: true, }, ], usesInheritance: true, ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: SelectValueAccessorDirective, decorators: [{ type: Directive, args: [{ standalone: false, /* tslint:disable-next-line:directive-selector */ selector: 'ion-select, ion-radio-group, ion-segment, ion-datetime', providers: [ { provide: NG_VALUE_ACCESSOR, useExisting: SelectValueAccessorDirective, multi: true, }, ], }] }], ctorParameters: () => [{ type: i0.Injector }, { type: i0.ElementRef }], propDecorators: { _handleChangeEvent: [{ type: HostListener, args: ['ionChange', ['$event']] }] } }); //# sourceMappingURL=select-value-accessor.js.map