Angular6 Date time check with ngIf inside html template
Angular6 Date time check with ngIf inside html template
I am using Angular6
.
Angular6
Below is the ngfor
with div. Here the api outputs the meeting date and time with status. Normally the status is upcoming.
ngfor
If the date time is 09/18/2018. and Time is 5.30 Pm.
<div class="col-sm-12" *ngFor="let todayinfo of todaylist | paginate: id: 'todaypage', itemsPerPage: itemperpage, currentPage: page, totalItems: todaytotal">
<div class="meeting-date-time" title="Date Time" >
todayinfo.meeting_date <br>todayinfo.displayTime
</div>
<div>todayinfo.status </div>
</div>
The upcoming status should be changed as Join
, before 15 minutes of the meeting time.
Join
i.e at Sep 18 at 5.15pm the content need to change as Join
. Here how to check the date time check condition. It is displayed inside the loop. If there is any click action we will check this with separate function. Without any events how to check the date time condition here?
Join
Now the Output is
Sep 18 2018 5.30 PM --- Upcoming
Sep 4 2018 9.00 AM -- Completed
Spe 17 2018 7.15 PM -- Upcoming
These upcoming
need to change to Join
before 15 min of the corresponding date time.
upcoming
Join
1 Answer
1
There is simple solution how you can achieve that:
const meetings = [
meeting_date: new Date(2018, 8, 17, 11, 44), status: null,
meeting_date: new Date(2018, 8, 17, 12, 45), status: null
];
const today = new Date();
meetings.filter(meeting => (meeting.meeting_date.getTime() - today.getTime()) <= 900000).forEach(meeting => meeting.status = 'Join');
It will check for meeting where time difference is less or equal to 900000(15min) and mark their status as 'Join'.
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy
Initially, you can check that when user enter the site and list is displayed then set up maybe every minute simple check for time and update status.
– Buczkowski
Sep 17 '18 at 9:25