I have a date field and I want to remove the place holder by default.
I am using javascript onfocus
and onfocusout
events for removing placeholder.
Can anyone help with using angular2 directive?
<input name="date" type="text" onfocus="(this.type='date')" onfocusout="(this.type='text')" class="dateinput">
I try to solving in this way, but i am getting problem with resetting the input field type.
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);
}
}