mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-15 17:42:15 +08:00
28 lines
708 B
TypeScript
28 lines
708 B
TypeScript
import { Directive, ElementRef, HostListener, Injector } from '@angular/core';
|
|
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
|
|
import { ValueAccessor } from './value-accessor';
|
|
|
|
@Directive({
|
|
/* tslint:disable-next-line:directive-selector */
|
|
selector: 'ion-input:not([type=number]),ion-textarea,ion-searchbar',
|
|
providers: [
|
|
{
|
|
provide: NG_VALUE_ACCESSOR,
|
|
useExisting: TextValueAccessor,
|
|
multi: true
|
|
}
|
|
]
|
|
})
|
|
export class TextValueAccessor extends ValueAccessor {
|
|
|
|
constructor(injector: Injector, el: ElementRef) {
|
|
super(injector, el);
|
|
}
|
|
|
|
@HostListener('ionChange', ['$event.target'])
|
|
_handleInputEvent(el: any) {
|
|
this.handleChangeEvent(el, el.value);
|
|
}
|
|
}
|