How to show empty message in data table angular material, If no data found

前端 未结 18 742
别那么骄傲
别那么骄傲 2021-01-07 16:51

I am using this code

 
  
    

        
18条回答
  •  北海茫月
    2021-01-07 17:13

    It's like bugs is saying, you can just use *ngIf. Compare these two tables here:

    https://stackblitz.com/edit/angular-w9ckf8

    My empty table
    
    
        
            Name 
             {{element.name}} 
        
    
        
            Age 
             {{element.age}} 
        
        
        
        
    
    
    
    No records found

    My full table Name {{element.name}} Age {{element.age}}
    No data

    TS with data:

    displayedColumns = ['Name', 'Age']
    dataSource = [{name:'Sara',age:17}, {name: 'John', age: 20}]
    dataSourceEmpty = []
    

提交回复
热议问题