Array display meteor inside the collection

I want to create a message model with tags and be able to display all the tags for each message. Do you know the best way to do this?

I tried this

<template name='postsLists'> {{#each post}} {{> postDetails }} {{/each}} </template> <template name='postDetails'> title: {{title}} {{#each tag}} {{tag}} {{/each}} </template> 
+6
source share
2 answers

To get the value from the array, use this keyword

 <template name='postDetails'> title: {{title}} {{#each tag}} {{this}} {{/each}} </template> 
+10
source

This code will not work:

 {{#each tag}} {{tag}} {{/each}} 

because the β€œtag” here refers to both the list and the item in this list. Try:

 {{#each tags}} {{tag}} {{/each}} 
+2
source

All Articles