-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Closed
Description
I have a component that has some md-input-container elements. I would like to set focus on the first one when the view loads.
The way I am implementing this is by creating a @ViewChild property and then calling focus on it ngAfterViewInit. There are no errors but, the focus is still not working.
export class AdminUserComponent implements AfterViewInit {
@ViewChild(MdInputContainer)
private firstInput: MdInputContainer;
ngAfterViewInit() {
this.firstInput._mdInputChild.focus();
}
}
I tried setting the focus code in a setTimeout function but that didn't make a difference. Has anyone successfully set focus on a material input when the view loads?
Metadata
Metadata
Assignees
Labels
No labels