PrimeNG:p-autoComplete不清除值

时间:2017-05-31 09:11:35

标签: html angularjs primeng

我正在使用PrimeNG。我为自动完成编写了如下代码

<p-autoComplete name="searchSuggestions" [(ngModel)]="suggestion" 
(completeMethod)="searchSuggestions($event)" [suggestions]="searchSuggestionsResult" field="field"></p-autoComplete>

我正在清除方法中的suggestion,但不清除自动填充输入值。只有在我从建议中选择时才能清除。

this.suggestion = undefined;

2 个答案:

答案 0 :(得分:1)

使用onClear()方法&amp;设置模型值= null。

==== HTML

(onClear)="clearValue()

== TS

clearValue()
{
    this.suggestion = null;
}

只有清除了自动完成列表中的所有值后才会调用此函数。

希望这会有效!!

答案 1 :(得分:0)

请将primeng版本升级到"primeng": "^1.1.1",然后这样就可以了。