使用 blaze 显示嵌套数据
Displaying nested data with blaze
我已经在我的 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();
}
});
您需要删除 ../
<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>
```
我已经在我的 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();
}
});
您需要删除 ../
<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>
```