May i know how to match the “datetime” value = today on each Match?
.js
Template.List_matches_page.helpers({
isToday: function () {
const today = new Date();
const matchdate = Matches.find({}, {datetime: today});
});
.html
{{#each match in matches}}
{{#if isToday}}
ZZZZZZZZZZZZZZZZZZZZZZ
{{else}}
AAAAAAAAAAAAAAAAAA
{{/if}}
{{/each}}
but how to use it in .html?
I take it you are new to Meteor.
There are 2 ways depending how you need this data.
- Publish it from the server (see Meteor Pub/Sub). In very brief, publish on the server, subscribe from the client (Publish and subscribe | Meteor API Docs)
- Fetch this data with a Meteor Method. Declare the method on either server side or common (both server and client): Methods | Meteor Guide
Would you please give some hint?
I would like to highlight red when the match.datetime = today, Am i correct below?
{{#each match in matches}}
<tr class="center aligned" {{#if isToday match.datetime }} bgcolor= "red" {{/if}}>
<td>
{{match.datetime}}
</td>
</tr>
{{/each}}
Template.List_matches_page.helpers({
matches() {
return Matches.find({}, {sort: {datetime: -1}});
},
isToday(datematch) {
const today = new Date();
return datematch === today;
},
});