0
我有問題的集合,用一個id每個問題:Meteor.js路由與陣列
[
{
id: 0,
question: "What's up?"
},
.....
我也有問題列表/陣列的集合。列表/數組中的每個項目都是問題ID。
我有一個模板鏈接到該列表中的問題:
<template name="questionListIDContent">
{{#each question}}
<a href="{{pathFor 'myQuestion'}}" class="discuss btn btn-default btn-sm">Answer</a>
{{/each}}
</template>
的路線是:
Router.route('/myquestion/:_id', {
name: 'myQuestion',
data: function() {
return Questions.findOne(this.params._id);
}
});
助手是:
Template.questionListIDContent.helpers({
question: function() {
var temp = QuestionsList.findOne({id: this.lessonID});
var temp2 = temp.questionID // Array of question IDs
return Questions.findOne({id: { $in: temp2 }});
}
});
我想將findOne與包含問題列表的數組一起使用,以獲取要在模板中使用的必需問題。有人看到我在這裏做錯了嗎?有沒有更好的辦法。
當然。我覺得自己像個白癡!謝謝!! – user3393285