mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-10 00:27:41 +08:00
28 lines
781 B
TypeScript
28 lines
781 B
TypeScript
import { ElementRef, Injector, Directive, 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-radio',
|
|
providers: [
|
|
{
|
|
provide: NG_VALUE_ACCESSOR,
|
|
useExisting: RadioValueAccessorDirective,
|
|
multi: true,
|
|
},
|
|
],
|
|
})
|
|
export class RadioValueAccessorDirective extends ValueAccessor {
|
|
constructor(injector: Injector, el: ElementRef) {
|
|
super(injector, el);
|
|
}
|
|
|
|
// TODO(FW-2827): type (HTMLIonRadioElement and HTMLElement are both missing `checked`)
|
|
@HostListener('ionSelect', ['$event.target'])
|
|
_handleIonSelect(el: any): void {
|
|
this.handleValueChange(el, el.checked);
|
|
}
|
|
}
|