admin管理员组文章数量:1289634
I want create a posts model, with tags, and be able to display all tags for each post. You know a best way to do it ??
I tried this
<template name='postsLists'>
{{#each post}}
{{> postDetails }}
{{/each}}
</template>
<template name='postDetails'>
title: {{title}}
{{#each tag}}
{{tag}}
{{/each}}
</template>
I want create a posts model, with tags, and be able to display all tags for each post. You know a best way to do it ??
I tried this
<template name='postsLists'>
{{#each post}}
{{> postDetails }}
{{/each}}
</template>
<template name='postDetails'>
title: {{title}}
{{#each tag}}
{{tag}}
{{/each}}
</template>
Share
Improve this question
edited Jan 8, 2013 at 16:15
Nonyck
asked Jan 8, 2013 at 16:10
NonyckNonyck
6821 gold badge13 silver badges29 bronze badges
1
- Can you explain what exactly isn't working? – Rahul Commented Jan 8, 2013 at 16:26
2 Answers
Reset to default 10You need to use this
keyword to get value from an array:
<template name='postDetails'>
title: {{title}}
{{#each tag}}
{{this}}
{{/each}}
</template>
This code won't work:
{{#each tag}}
{{tag}}
{{/each}}
because "tag" here refers to both the list and an element in that list. Try:
{{#each tags}}
{{tag}}
{{/each}}
本文标签: javascriptMeteor display array inside a collectionStack Overflow
版权声明:本文标题:javascript - Meteor display array inside a collection - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741398952a2376546.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论