【发布时间】:2015-11-13 09:50:11
【问题描述】:
我在理解在流星中使用每个循环时遇到了一些问题。因为我的数据库有以下 SimpleSchema...
collection.js
dGroup = new SimpleSchema({
title: { type: String, optional: true },
element: { type: [more], optional: true }
});
more = new SimpleSchema({
description: { type: String, optional: true },
anything: { type: String, optional: true }
});
MongoDB.attachSchema(new SimpleSchema({
mainTitle: { type: String },
slug: { type: String, unique: true },
language: { type: String, defaultValue: "en" },
group: { type: [dGroup], optional: true },
}));
router.js
data: function () {
return {
result: MongoDB.findOne({
_id: this.params._id
})
};
}
...我想在每个循环中使用每个循环:
{{#each result.group}}
<table>
<caption>{{mainTitle}}</caption>
<tbody>
{{#each element}}
<tr>
<td><input type="text" value="{{description}}"></td>
<td><input type="text" value="{{anything}}"></td>
</tr>
{{/each}}
</tbody>
</table>
{{/each}}
更新
我的问题是如何使用父元素中的元素。在此示例中,我无法访问 {{mainTitle}},因为它是 while 循环的父元素。
【问题讨论】:
标签: javascript meteor