]>
Commit | Line | Data |
---|---|---|
a3664dfd C |
1 | import { AfterViewInit, Directive, ElementRef } from '@angular/core' |
2 | ||
3 | @Directive({ | |
9df52d66 | 4 | selector: '[myAutofocus]' |
a3664dfd C |
5 | }) |
6 | export class AutofocusDirective implements AfterViewInit { | |
7 | constructor (private host: ElementRef) { } | |
8 | ||
9 | ngAfterViewInit () { | |
04c2dcfc C |
10 | const el = this.host.nativeElement as HTMLElement |
11 | ||
12 | el.focus({ preventScroll: true }) | |
a3664dfd C |
13 | } |
14 | } |