I am trying to use enter key press event in angular and I am using ng-select for dropdown list but I am not able to get element reference of ng-select as it not native element of HTML ,I did use @ViewChildren and @ViewChild, but still I am not able get reference
<ng-select class="form-control" #cityInput formControlName="city" [items]="cities" (keydown)="onEnterKeyPress1($event)"> </ng-select>
this is my snippet in component.html, here I have given #cityInput reference and following is the code where I am trying to use this reference
@ViewChildren(
' cityInput ') inputElement: QueryList<NgSelectComponent>;
how can i use focus method on ng-select
We need to use
ViewChildto select a single element, we can useViewChildrento select multiple children, we can either pass the reference or we can give the class directly as input and it will fetch the values after the view is loaded, so its important we access the values after the view has initializedngAfterViewInit!stackblitz