Skip to content

Instantly share code, notes, and snippets.

@SnisarOnline
Created July 6, 2019 18:23
Show Gist options
  • Save SnisarOnline/4ee75678f0f7235afa6dd2e9b2da0404 to your computer and use it in GitHub Desktop.
Save SnisarOnline/4ee75678f0f7235afa6dd2e9b2da0404 to your computer and use it in GitHub Desktop.
Autofocus
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