5
に各ネストん:はなぜテンプレートの出力は何も
{{#each Items}} // a collection
{{title}}
{{/each}}
{{#each types}} // another ollection
{{refId}}
{{/each}}
私はそれを一緒に置く場合:
{{#each Items}}
{{title}}
{{#each types}}
{{refId}}
{{/each}}
{{/each}}
#each types
は空です。
テンプレートヘルパー:
Template.menuItems.helpers({
restMenuItems: function() {
return RestMenuItems.find({restRefId: this._id}, {sort:Template.instance().sort.get()});
},
restMenuSideItems: function() {
return RestMenuSideItems.find({restRefId: this._id}, {sort:Template.instance().sort.get()});
}
});
Template.menuItems.onCreated(function(){
this.subscribe('restMenuItems');
this.subscribe('restMenuSideItems');
});
とテンプレートコードの一部:
{{#each restMenuItems}}
<div>
<select class="list-group select_side_addons">
{{#each restMenuSideItems}}
<option>{{restRefId}}</option>
{{/each}}
</select>
</div>
{{/each}}
{{#each ../restMenuSideItems}}
で{{#each restMenuSideItems}}
を交換しても、何も表示されません。
どういうところが間違っていますか?
ありがとうございますが、それでも同じです。 –
奇妙な、それはうまくいくはずです。より多くのコード(例:ヘルパーや完全なテンプレートコード)を提供できますか? 'Items'と' types'はどこから来たのですか? – MasterAM
ちょうどしました。 @MasterAM –