Search code examples
angularangular-materialmat-table

How to filter Angular Material table field with value timestamp?


dataSource

    [
        {name:'User1',date:1605082722360},
        {name:'User2',date:1605022729782}
    ]

list.component.html

<table mat-table [dataSource]="dataSource" matSort class="mat-elevation-z8">
        <ng-container matColumnDef="name">
            <th mat-header-cell *matHeaderCellDef mat-sort-header>Name </th>
            <td mat-cell *matCellDef="let element" [attr.title]="element.name">{{element.name}}</td>
        </ng-container>
        <ng-container matColumnDef="date">
            <th mat-header-cell *matHeaderCellDef mat-sort-header>Date </th>
            <td mat-cell *matCellDef="let element" [attr.title]="element.date">{{element.date | date}}</td>
        </ng-container>
</table>

enter image description here

please help me to filter mat-table, for example nov 10 from above dataSource?


Solution

  • setting the custom filterPredicate method helps you to solve this issue, please refer the stackblitz link mentioned below

    stackblitz