我想添加“无记录消息”如果有人搜索当前表显示空数据!
以下是角度js中样本材料表的链接
https://material.angular.io/components/table/examples
解决方法:
我找到了确切的解决方案
在打字稿中:
applyFilter(filterValue: string) {
filterValue = filterValue.trim(); // Remove whitespace
filterValue = filterValue.toLowerCase(); // MatTableDataSource defaults to lowercase matches
this.dataSource.filter = filterValue;
if(this.dataSource.filteredData.length==0){
this.displayNoRecords=true;
}else{
this.displayNoRecords=false;
}
}
在模板中
<mat-card *ngIf="displayNoRecords" style="padding:100px;">
<h3 style="text-align:center">We couldn't find data for
<span style="color:red">"{{dataSource.filter}}"</span><br>
Make sure the label,type or status are spelled and formatted correctly
</h3>
</mat-card>
原文地址:https://codeday.me/bug/20190522/1153231.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。