I have following angular:
ngOnInit(){
this.getInfo().then((data) => {
this.allInfo= data;
});
};
...where the data
looks like below:
0:
Time: 1508218791131
1:
Time: 1508217179413
2:
Time: 1508217026810
Then, in html:
<div *ngFor = "let each of allInfo;" >
<div>{{ each.Time | date : "shortTime" }}</div>
</div>
These works just fine.
Here is what I am trying to do:
I am trying to compare the Time
to the current time
with two conditions:
- If it has been less than 24 hours compared to the current time, then use "shortTime" giving
11:10 pm
- If it has been more than 24 hours compared to the current time, then use "MMM d" giving
Oct 16
.
How do I add the if condition to the syntax inside of ngFor?