I have this:
Template.laps_t.laps = function () {
return Practices.findOne({name: Session.get('practice')});
};
What do I have to do to iterate over this and put the values in paragraphs? I mean:
{{#each laps.lapList}}
<p>WHAT DO I HAVE TO PUT HERE TO PRINT THE VALUES OF THE LIST????</p>
{{/each}}
Am I doing this right? What do I have to put inside that paragraph?
EDIT:
Thanks Justin Case, your solution did the trick.
Now I have one more problem. I want to print no only lap.lapList
but also lap.lapTimeList
(which is another list like [1,2,3,4,5,...]
) in a table like so:
{{#each laps.lapList}}
<tr>
<td>iterate over and print the current value of lapList (solved using {{this}})</td>
<td>iterate over and print the current value of lapTimeList</td>
</tr>
{{/each}}
laps
is the object that holds both lapList
and lapTimeList
. So, the idea is to print the lap number and the respective time. Does anyone knows how?
If laps.lapList
is an array in the form of [1,2,3]
then:
{{#each laps.lapList}}
<p>{{.}}</p>
{{/each}}
{{.}}
refers to the current object/element. If it contains a dictionaries/hashes e.g. [{elapsedTime:32.0, location: 'Chicago'}]
then you can use the key name:
{{#each laps.lapList}}
<p>Lap took {{elapsedTime}}</p>
{{/each}}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With