Headless CMS and Content Managment Hub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

32 lines
757 B

/*
* Squidex Headless CMS
*
* @license
* Copyright (c) Sebastian Stehle. All rights reserved
*/
import { Directive, ElementRef, Input, OnInit, Renderer } from '@angular/core';
@Directive({
selector: '[sqxFocusOnInit]'
})
export class FocusOnInitDirective implements OnInit {
@Input()
public select: boolean;
constructor(
private readonly elementRef: ElementRef,
private readonly renderer: Renderer
) {
}
public ngOnInit() {
setTimeout(() => {
this.renderer.invokeElementMethod(this.elementRef.nativeElement, 'focus', []);
if (this.select) {
this.renderer.invokeElementMethod(this.elementRef.nativeElement, 'select', []);
}
});
}
}