fixed autofocus in input fields (fixes #374)

This commit is contained in:
Eugene Pankov
2018-09-10 17:23:36 +02:00
parent 38e450f70a
commit d6fb71dca2
4 changed files with 22 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
import { Directive, AfterViewInit, ElementRef } from '@angular/core'
@Directive({
selector: '[autofocus]'
})
export class AutofocusDirective implements AfterViewInit {
constructor (private el: ElementRef) { }
ngAfterViewInit () {
this.el.nativeElement.blur()
setTimeout(() => {
this.el.nativeElement.focus()
})
}
}