Tôi có trường ngày tháng và tôi muốn xóa trình giữ chỗ theo mặc định.
Tôi đang sử dụng javascript onfocus
và onfocusout
các sự kiện để xóa trình giữ chỗ.
Bất cứ ai có thể giúp đỡ với việc sử dụng chỉ thị angle2?
<input name="date" type="text" onfocus="(this.type='date')" onfocusout="(this.type='text')" class="dateinput">
Tôi cố gắng giải quyết theo cách này, nhưng tôi gặp sự cố khi đặt lại loại trường nhập.
import { Directive, ElementRef, Input } from 'angular2/core';
@Directive({
selector: '.dateinput',
host: {
'(focus)': 'setInputFocus()',
'(focusout)': 'setInputFocusOut()',
}})
export class MyDirective {
constructor(el: ElementRef) { this.el = el.nativeElement; console.log(this.el);}
setInputFocus(): void {
//console.log(this.elementRef.nativeElement.value);
}
}
dateinput
?