【问题标题】:I'm using primeng auto-complete 5.2.4, I need to display the suggestions on focus of the control我正在使用primeng auto-complete 5.2.4,我需要显示关于控件焦点的建议
【发布时间】:2018-06-15 03:06:11
【问题描述】:

我正在使用primeng auto-complete 5.2.4,我需要显示关于控件焦点的建议。

<p-autoComplete [(ngModel)]="model" [suggestions]="Suggestions" 
  (completeMethod)="filter($event)" field="Value" [required]="true" 
 [forceSelection]="true" [minLength]="0">
</p-autoComplete>

我添加了minLength="0" 并尝试了各种其他方式,但未能成功显示关于焦点的建议。感谢任何帮助。

【问题讨论】:

    标签: angular autocomplete primeng


    【解决方案1】:

    只需像这样使用onFocus 事件调用show()

    (onFocus)="autoComplete.show()"
    

    但您需要定义autoComplete 模板才能访问show()。完整的组件声明是:

    <p-autoComplete
      #autoComplete
      [(ngModel)]="model"
      [suggestions]="Suggestions" 
      (completeMethod)="filter($event)"
      (onFocus)="autoComplete.show()"
      field="Value"
      [required]="true"
      [forceSelection]="true"
      [minLength]="0"></p-autoComplete>
    

    您可以在这里看到一个工作示例: https://stackblitz.com/edit/angular-qwpqgp

    【讨论】:

    • 您能否在 *ngFor 中发布 p-autoComplete 的工作示例。 onBlur() 和选择一个选项有时不起作用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-11-30
    • 2021-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-02
    相关资源
    最近更新 更多