How to sort Date/Time column in angular 4 material sort?

前端 未结 5 595
借酒劲吻你
借酒劲吻你 2021-02-13 21:08

I\'m using angular material table and using matSort for sorting. But it\'s not sorting the dates/time column. It takes the datetime column values as strings.

How to sor

5条回答
  •  别跟我提以往
    2021-02-13 21:32

    With the latest version of Angular Material 5, you should add just a property "mat-sort-header" and it will sort out of the box. Also, you could add some DatePipe so you can format that Date object.

    
      
         
           date
        
         
           {{row.fromDate | date: 'dd MMM., yyyy, HH:mm' }}
        
      
    
    

    I also think Andriy has already helped with this plnkr (plnkr.co/edit/z1BmTxFWAEvWQuMIAXCv?p=preview)

提交回复
热议问题