Set Focus on ng-select by Code
See original GitHub issueI create 2 ng-select on 1 page like below
<ng-select [items]="dataOffice" bindLabel="office_name" bindValue="office_code" placeholder="- Select -" #office="ngModel" (keydown.enter)="keytab($event, 'customer')" name="office"> </ng-select>
<ng-select [items]="dataCustomer" bindLabel="customer_name" bindValue="customer_code" placeholder="- Select -" #customer="ngModel" id="customer" name="customer"> </ng-select>
and then i set event (keydown.enter) on office so when i press enter the focus will change to customer
keytab(event, target) { let nextElm = this.renderer2.selectRootElement('#' + targetElm); nextElm.focus(); }
Its work on input or normal select, but when on ng-select the focus not changed to customer dropdown and the dropdown become blank.
Can you advice?
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (3 by maintainers)
Top GitHub Comments
there is no need, latest version has method
focus
.#select.focus()
If it helps someone, I’ve managed to set focus on ng-select input element this way:
this.ngSelectInput.filterInput.nativeElement.focus();