我有上面的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
更多推荐
发布评论