简体   繁体   English

如何设置默认值 <p-autocomplete> 启动标签

[英]how to set default value in <p-autocomplete> tag of primeng

I want to set default value in tag, It seems that tag doesn't have default value property..is there any way to do so..please help me.. . 我想在标签中设置默认值,似乎标签没有默认值属性。是否有任何方法可以..请帮助我。 I am using this..its showing suggestions but not able to set default value. 我正在使用this..it显示建议,但无法设置默认值。

In HTML, try this: 在HTML中,尝试以下操作:

[ngModelOptions]="{standalone: true}"

For Example: 例如:

<p-autoComplete [ngModelOptions]="{standalone: true}" [(ngModel)]="text" [suggestions]="results" (completeMethod)="search($event)"></p-autoComplete>

I fixed the same issue by adding this in html. 我通过在html中添加此问题解决了同一问题。 Good Luck!!! 祝好运!!!

Try this 尝试这个

<p-autoComplete [(ngModel)]="text" [suggestions]="results" (completeMethod)="search($event)"></p-autoComplete>

in component.ts File

this.text = 'yourValue'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM