我已将此嵌套数据插入我的minimongo
db.orders.insert({
_id: ObjectId().str,
name: "admin",
status: "online",catalog : [{
"objectid" : ObjectId().str,
"message" : "sold",
"status" : "open"
}]
});
我试图用这段代码显示它
<template name="Listed">
<div class="row">
{{#each list}}
<article class="post">
<a href="{{pathFor route='edit'}}"><h3>{{_id}}</h3></a>
<a href="{{pathFor route='edit'}}"><h3>{{name}}</h3></a>
<br>
<a href="{{pathFor route='create'}}"><h3>{{status}}</h3></a>
<br>
{{#each ../catalog}}
<a href="{{pathFor route='create'}}"><h3></h3></a>
<a href="{{pathFor route='create'}}"><h3>{{status}}</h3></a>
{{/each}}
<div class="well"></div>
<br/>
</article>
<br/><br/>
{{/each}}
</div>
</template>
但未显示嵌套数据。如何显示嵌套数据?。
这是我的数据助手
/*****************************************************************************/
/* Listed: Helpers */
/*****************************************************************************/
Template.Listed.helpers({
'list': function(){
return Orders.find();
}
});
答案 0 :(得分:2)
您需要删除../
<template name="Listed">
<div class="row">
{{#each list}}
<article class="post">
<a href="{{pathFor route='edit'}}"><h3>{{_id}}</h3></a>
<a href="{{pathFor route='edit'}}"><h3>{{name}}</h3></a>
<br>
<a href="{{pathFor route='create'}}"><h3>{{status}}</h3></a>
<br>
{{#each catalog }}
<a href="{{pathFor route='create'}}"><h3></h3></a>
<a href="{{pathFor route='create'}}"><h3>{{status}}</h3></a>
{{/each}}
<div class="well"></div>
<br/>
</article>
<br/><br/>
{{/each}}
</div>
</template>
```