微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

javascript – 如果过滤器在材质表角度中没有结果,如何显示“无记录”

我想添加“无记录消息”如果有人搜索当前表显示空数据!

以下是角度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>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐