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






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




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

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)