Angular 没有数据时,角度剑道组合框无法隐藏
我正在使用angular和剑道,我使用剑道组合框来显示一些值 我想在没有数据匹配时隐藏弹出窗口,但我不能这样做Angular 没有数据时,角度剑道组合框无法隐藏,angular,typescript,kendo-combobox,Angular,Typescript,Kendo Combobox,我正在使用angular和剑道,我使用剑道组合框来显示一些值 我想在没有数据匹配时隐藏弹出窗口,但我不能这样做 请帮帮我。当data.length为零且combobox.isOpen为false时,您必须在筛选函数中使用[combobox.toggle()][1] 模板 <div class="example-wrapper"> <kendo-combobox #combo [data
请帮帮我。当
data.length
为零且combobox.isOpen
为false时,您必须在筛选函数中使用[combobox.toggle()][1]
模板
<div class="example-wrapper">
<kendo-combobox
#combo
[data]="data"
[textField]="'text'"
[valueField]="'value'"
[filterable]="true"
(filterChange)="handleFilter($event)"
[placeholder]="'T-shirt size'"
>
<ng-template kendoComboBoxNoDataTemplate>
No data found!
</ng-template>
</kendo-combobox>
</div>
没有找到任何数据!
组件
export class AppComponent {
@ViewChild('combo') combo:ComboBoxComponent
public source: Array<{ text: string, value: number }> = [
{ text: 'Small', value: 1 },
{ text: 'Medium', value: 2 },
{ text: 'Large', value: 3 }
];
public data: Array<{ text: string, value: number }>;
constructor() {
this.data = this.source.slice();
}
handleFilter(value) {
this.data = this.source.filter((s) => s.text.toLowerCase().indexOf(value.toLowerCase()) !== -1);
if(this.data.length == 0 && this.combo.isOpen){
this.combo.toggle()
}
}
}
导出类AppComponent{
@ViewChild('combo')组合:ComboBoxComponent
公共源:数组=[
{text:'Small',值:1},
{文本:'中等',值:2},
{文本:'Large',值:3}
];
公共数据:数组;
构造函数(){
this.data=this.source.slice();
}
handleFilter(值){
this.data=this.source.filter((s)=>s.text.toLowerCase().indexOf(value.toLowerCase())!=-1);
if(this.data.length==0&&this.combo.isOpen){
this.combo.toggle()
}
}
}
哇,太棒了,@hanan非常感谢你的帮助。