Filter results by Today with date pipe


#1

I’m trying to filter a json object, only showing results that match today’s date.

template.html

<ion-item-sliding *ngFor="let job of filteredJobs">
  <div *ngIf="(job.schedule | date: 'MM/dd/yy') == (today | date:'MM/dd/yy')">
    <h2>{{job.title}}</h2>
    <p>{{job.description}}</p>
  </div>
</ion-item-sliding>

I have the *ngIf statement wrong but I don’t know how to fix it.

today is declared in template.ts
today: String = new Date().toISOString();

I have printed out the variables and they are in fact identical 01/22/17. Thanks for any help!


#2

I would prefer to do this sort of work on the component side, instead of in the template, by creating a method that returns only today’s jobs.


#3

Good point @rapropos. I know pipe filtering can slow down the UX considerably.