mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
28 lines
683 B
TypeScript
28 lines
683 B
TypeScript
import { Directive, ElementRef, HostListener } from '@angular/core';
|
|
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
|
|
import { ValueAccessor } from './value-accessor';
|
|
|
|
@Directive({
|
|
/* tslint:disable-next-line:directive-selector */
|
|
selector: 'ion-range, ion-select, ion-radio-group, ion-segment, ion-datetime',
|
|
providers: [
|
|
{
|
|
provide: NG_VALUE_ACCESSOR,
|
|
useExisting: SelectValueAccessor,
|
|
multi: true
|
|
}
|
|
]
|
|
})
|
|
export class SelectValueAccessor extends ValueAccessor {
|
|
|
|
constructor(el: ElementRef) {
|
|
super(el);
|
|
}
|
|
|
|
@HostListener('ionChange', ['$event.target'])
|
|
_handleChangeEvent(el: any) {
|
|
this.handleChangeEvent(el, el.value);
|
|
}
|
|
}
|