The website page I'm working on pulls peoples' reviews from an API. One of the items in the returned JSON is the date the review was created. I want to display the review date(which I've done), but I also want to include how many days ago that review was created. I'm using *ngFor to loop through all the reviews.
<div *ngFor="let review of reviews.data.beerReviews.items">
<div>{{review.createdAt | date}}</div> //displays date of the review as expected
//here I want to display the number of days ago the review was made
</div>
I tried creating a property for today's date:
today: number=Date.now();
then I tried to have it do the math:
{{today|date - review.createdAt|date}}
It of course doesn't work, the error in the console:
Parser Error: Unexpected token '-' at column 12 in [{{today|date - review.createdAt|date}}]
I'm new to all this, so hopefully I've explained it well, thank you.