У меня есть поле даты, и я хочу удалить держатель места по умолчанию.
Я использую javascript onfocus и onfocusout для удаления placeholder.
Может ли кто-нибудь помочь с использованием директивы angular2?
<input name="date" type="text" onfocus="(this.type='date')" onfocusout="(this.type='text')" class="dateinput">
Я пытаюсь решить таким образом, но у меня возникает проблема с сбросом типа поля ввода.
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);
}
}