mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 01:33:33 +00:00
move various angular bits into shared jslib
This commit is contained in:
24
src/angular/directives/autofocus.directive.ts
Normal file
24
src/angular/directives/autofocus.directive.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import {
|
||||
Directive,
|
||||
ElementRef,
|
||||
Input,
|
||||
} from '@angular/core';
|
||||
|
||||
@Directive({
|
||||
selector: '[appAutofocus]',
|
||||
})
|
||||
export class AutofocusDirective {
|
||||
@Input() set appAutofocus(condition: boolean | string) {
|
||||
this.autofocus = condition === '' || condition === true;
|
||||
}
|
||||
|
||||
private autofocus: boolean;
|
||||
|
||||
constructor(private el: ElementRef) { }
|
||||
|
||||
ngOnInit() {
|
||||
if (this.autofocus) {
|
||||
this.el.nativeElement.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user