我试图在输入文本长度超过 3 后显示搜索结果如果文本长度小于 3,我想隐藏搜索结果区域。我只能使用 inputId 作为标识符。如何在启动下拉列表中实现这一点。
app.component.html:
<p-dropdown
[options]="cars"
inputId="listDDOne"
[(ngModel)]="selectedCar"
[style]="{'width':'100%'}"
scrollHeight="400px"
filter="true"
resetFilterOnHide="true"
(keydown.enter)="MyKeydownEnter($event)"
(keydown)="MyKeydown($event)"
(onChange)="OnChange($event)">
<ng-template let-item pTemplate="selectedItem">
{{item.label}}
</ng-template>
<ng-template let-car pTemplate="item">
<div class="drop-item"
(click)="MyItemClick($event)">
<span class="drop-item-label"
[ngClass]="car.disabled ? 'disabled' : ''">
{{car.label}}
</span>
<span class="drop-item-value"
[ngClass]="car.disabled ? 'disabled' : ''">
{{car.value}}
</span>
</div>
</ng-template>
</p-dropdown>
app.component.ts:
MyKeydown(event) {
console.log("MyKeydown", event.value);
if(event.value.length>3){
event.stopPropagation();
event.preventDefault();
????
}
}