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>
You 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}}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.