角度材料:如何清除建议?(Angular Material: How to clear suggestions?)

编程入门 行业动态 更新时间:2024-10-25 10:27:26
角度材料:如何清除建议?(Angular Material: How to clear suggestions?) <md-autocomplete ng-model="ctrl.searchText" md-selected-item="ctrl.selectedItem" md-selected-item-change="ctrl.selectedItemChange(item)" md-search-text="ctrl.searchText" md-search-text-change="ctrl.searchTextChange(ctrl.searchText)" md-items="item in ctrl.querySearch(ctrl.searchText)" md-item-text="item.display" md-min-length="0" placeholder="Start typing your search term here">

我有上面的md-autocomplete 。

如何在行动中明确提出建议? (通过清除我的意思是删除缓存的结果集,以便不再有任何建议)。 目前我的querySearch函数是:

function querySearch(query) { var results = query ? $this.possibles.filter(createFilterFor(query)) : $this.possibles; return results; }

我的行动是设置$this.possibles = null但这仍然没有清除建议。 我们怎样才能做到这一点?

<md-autocomplete ng-model="ctrl.searchText" md-selected-item="ctrl.selectedItem" md-selected-item-change="ctrl.selectedItemChange(item)" md-search-text="ctrl.searchText" md-search-text-change="ctrl.searchTextChange(ctrl.searchText)" md-items="item in ctrl.querySearch(ctrl.searchText)" md-item-text="item.display" md-min-length="0" placeholder="Start typing your search term here">

I have the above md-autocomplete.

How can I make the suggestions clear on an action? (By clear I mean remove cached result set so that there are no longer any suggestions). Currently my querySearch function is:

function querySearch(query) { var results = query ? $this.possibles.filter(createFilterFor(query)) : $this.possibles; return results; }

My action is setting $this.possibles = null but this still doesn't clear the suggestions. How can we achieve this?

最满意答案

目前无法清除缓存,只能禁用它。 一段时间后材料仓库上有一个PR,但它已被搁置: https : //github.com/angular/material/pull/7421

因此,目前,唯一的方法是完全禁用缓存机制。 为此,您必须在自动填充中添加md-no-cache="true" 。

文档: https : //material.angularjs.org/HEAD/api/directive/mdAutocomplete

Currently there is no way to clear the cache, you can only disable it. There was a PR on the material repo a while back, but it has been put on hold: https://github.com/angular/material/pull/7421

So, for now, the only way is to completely disable the cache mechanism. To do that you have to add md-no-cache="true" to your autocomplet.

Docs: https://material.angularjs.org/HEAD/api/directive/mdAutocomplete

更多推荐

本文发布于:2023-07-22 12:20:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1219969.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:角度   建议   材料   Angular   clear

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!