如何从 PrimeNG 自动完成中聚焦到输入框?

How to focus into an input box from PrimeNG autocomplete?

我想在 PrimeNg autocomplete onSelect 事件点击后关注 inputbox

<p-autoComplete [(ngModel)]="itemIdAuto" name="itemIdAuto1" #itemIdAuto1="ngModel" size="15" 
[suggestions]="filteredItemIdAutoSingle" (completeMethod)= "itemIdAutoComplete($event)" field="name" 
(onSelect)="itemOnSelect(itemIdAuto)" placeholder= "Select Item Name" [minLength]="1"></p-autoComplete>

<input type="number" autocomplete="off" style="font-size:12px" class="form-control" name="qty"
[(ngModel)]="model.qty" #qty="ngModel">

打字稿:

import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';

export class GridFormComponent implements OnInit {

constructor() {
}

ngOnInit() {
}
@ViewChild('aForm') aForm: ElementRef;

itemOnSelect(item) {        
    this.aForm.nativeElement['qty'].focus();
    }
}

看看这个linkstackblitz

希望对你有所帮助,有什么问题可以私信我

谢谢

我正在根据您在下面看到的最后一条评论添加另一个答案 link 如果您发现任何问题请告诉我。

还有一点要关注我使用过的元素 jquery 所以请注意。

stackblitz

谢谢