Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to programmatically focus on dropdowns

Using the Angular 2 Dropdowns, how can I programmatically set focus to it? the examples show how to get the focus event, but not how to set focus.

thanks

like image 230
idekkers Avatar asked Nov 28 '25 18:11

idekkers


1 Answers

Let's assume your dropdowns are select, for i don't know what a kendo dropdown is. Start by creatign a local variable :

<select #dropdown></select>

In your component, get that variable reference :

@ViewChild() dropdown: ElementRef;

Now, you can trigger the focus with

this.dropdown.nativeElement.focus();

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!