Skip to content

Instantly share code, notes, and snippets.

@ZhenDeng
Last active February 3, 2020 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZhenDeng/29388c0684208ac635675bcbc6813a06 to your computer and use it in GitHub Desktop.
Save ZhenDeng/29388c0684208ac635675bcbc6813a06 to your computer and use it in GitHub Desktop.
HTML:
<input type="submit" class="btn btn-login register-submit" (click)="keyboardFocus(focusChange)" value="Stay on the page" #focusChange>
Component:
@ViewChild('focusChange') elChange: ElementRef;
setTimeout(() => {
this.elChange.nativeElement.focus();
}, 100
keyboardFocus(event): void {
event.style.outline = "2px solid blue";
}
// used for angular material layout
keyboardMatTableFocus(event): void {
event.srcElement.style.outline = "2px solid blue";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment