mirror of
https://github.com/lainbo/component-party.git
synced 2026-04-05 13:09:03 +08:00
19 lines
403 B
TypeScript
19 lines
403 B
TypeScript
import {
|
|
afterNextRender,
|
|
Component,
|
|
ElementRef,
|
|
viewChild,
|
|
} from "@angular/core";
|
|
|
|
@Component({
|
|
selector: "app-input-focused",
|
|
template: `<input type="text" #inputRef />`,
|
|
})
|
|
export class InputFocusedComponent {
|
|
inputRef = viewChild.required<ElementRef<HTMLInputElement>>("inputRef");
|
|
|
|
constructor() {
|
|
afterNextRender({ write: () => this.inputRef().nativeElement.focus() });
|
|
}
|
|
}
|