Ich habe ein Datumsfeld und möchte den Platzhalter standardmäßig entfernen.
Ich verwende Javascript onfocusund onfocusoutEreignisse zum Entfernen von Platzhaltern.
Kann jemand bei der Verwendung der Angular2-Direktive helfen?
<input name="date" type="text" onfocus="(this.type='date')" onfocusout="(this.type='text')" class="dateinput">
Ich versuche auf diese Weise zu lösen, aber ich habe Probleme beim Zurücksetzen des Eingabefeldtyps.
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?