Created
July 6, 2019 18:23
-
-
Save SnisarOnline/4ee75678f0f7235afa6dd2e9b2da0404 to your computer and use it in GitHub Desktop.
Autofocus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Directive, AfterViewInit, ElementRef } from '@angular/core'; | |
@Directive({ | |
selector: '[appAutofocus]' | |
}) | |
export class AutofocusDirective implements AfterViewInit { | |
constructor(private el: ElementRef) {} | |
ngAfterViewInit() { | |
this.el.nativeElement.focus(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment