-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Closed
Description
I'm having some trouble figuring out how to programmatically set focus on a <md-input>
used as a search bar. My application hides the input (sets a CSS class with display:none
) until the user clicks an icon indicating he'd like to perform a search. At this point, the CSS is changed (the class is removed) to reveal the input. I would like to automatically bring focus to it at this point. I've tried:
Template
<md-input [class.hidden]="searchOn" #searchbar>
<button (click)="onSearch(searchbar)">Start Search</button>
Component
onSearch(searchbar){
searchbar.focus(); // <-- Exception. focus is not a method
searchbar.focused = true; // <-- Exception. setting a property that has only a getter
}
How do you programmatically set focus on <md-input>
?
Metadata
Metadata
Assignees
Labels
No labels