【发布时间】:2016-11-24 11:49:54
【问题描述】:
我正在尝试迭代自定义内部数组对象“选择”。看下面的例子,“选择”里面可以有不同数量的对象。
{
_id: 1,
"question": "a",
"choices": [
{"a" : 1},
{"b" : "blablabla"},
{"c" : 128},
{"d" : "blebleble"}
],
"answer": "b",
"points": "10"
},
{
_id: 10,
"question": "j",
"choices": [
{"a" : 10},
{"b" : "blablabla"}
],
"answer": "b",
"points": "10"
}
我可以显示“问题”、“答案”、“分数”。
这是我在 main.html 中使用的模板
<template name="question">
<button>Click Me</button>
{{#with object}}
{{question}}
{{#each choices}}
??
{{/each}}
{{answer}}
{{points}}
{{/with}}
</template>
感谢任何帮助。如果你们需要更多信息,请告诉我。
【问题讨论】:
标签: meteor iteration handlebars.js