Kau*_*nki 5 angular-ngselect angular
我遇到的情况是,我需要在 ng-select 下搜索时根据自定义逻辑对数据进行排序。可以选择使用 [searchFn] 跨多个字段进行搜索,但我需要根据我的自定义逻辑对匹配结果进行排序。
ng-select:https://github.com/ng-select/ng-select
您可以侦听搜索事件并触发自定义函数来过滤数据集,然后修改 ng-select 具有的数据集。如果没有搜索到任何内容,您将需要管理重新填充下拉列表!
<ng-select (search)="onSearch($event)" [items]="data"></ng-select>
onSearch(e) {
// Do your custom filtering here to the total dataset and then reassign.
this.data = filtered_data;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2516 次 |
| 最近记录: |