Angular 角度ng-select2打开时搜索

Angular 角度ng-select2打开时搜索,angular,jquery-select2,angularjs-select2,Angular,Jquery Select2,Angularjs Select2,我希望用户可以在ng-select2打开时直接搜索。 这一次,用户打开ng-select2,需要用鼠标点击搜索字段并进行搜索-但搜索字段应直接关注打开ng-select2 有这样做的选择吗?我在谷歌上找不到任何东西:( 这是我的实际代码: HTML: 使用@ViewChild <ng-select2 #chooseInput [(ngModel)]="AUEEquip" (ngModelChange)="filterrole()&quo

我希望用户可以在ng-select2打开时直接搜索。 这一次,用户打开ng-select2,需要用鼠标点击搜索字段并进行搜索-但搜索字段应直接关注打开ng-select2

有这样做的选择吗?我在谷歌上找不到任何东西:(

这是我的实际代码: HTML:


使用
@ViewChild

<ng-select2 #chooseInput
      [(ngModel)]="AUEEquip"
      (ngModelChange)="filterrole()"
      name="AUEEquip"
      [allowClear]=true
      [data]="equips"
      [options]="options"
      [placeholder]="'Please choose your equipment'"
      style="text-align: left;">
      </ng-select2>

谢谢你的回答,但这对我不起作用。我已经导入了ViewChild并添加了你编写的代码,但当我打开ng-select2时,搜索字段不会自动获得焦点,就像我想在浏览器控制台上出错一样?不,ng-select2可以查找,搜索也可以-我只想“跳转”直接在打开ng-select2Like的搜索字段中,当我们单击下拉列表时,然后在select first控件中是文本框,需要自动选择它。当我单击ng-select2元素,下拉列表打开yes时,有一个文本框用于搜索,但它不会自动聚焦-但我希望它自动聚焦搜索字段。控制台中没有输出。
NgSelect2Module
您是否在模块内部导入了此模块?
  options = {
    width: '100%',
    multiple: false,
    tags: false
  };
  equips: Select2OptionData[] = [];
  AUEEquip: string = '0';
<ng-select2 #chooseInput
      [(ngModel)]="AUEEquip"
      (ngModelChange)="filterrole()"
      name="AUEEquip"
      [allowClear]=true
      [data]="equips"
      [options]="options"
      [placeholder]="'Please choose your equipment'"
      style="text-align: left;">
      </ng-select2>
@ViewChild('chooseInput')
chooseInput: any;

ngOnInit() {

//focus the element
this.chooseInput.nativeElement.focus();

}