Ho un elenco di attività e desidero caricare un elenco di commenti corrispondenti quando faccio clic su uno dei Task. Ferro Codice router:Contesto dati di accesso Meteor in onCreated
Router.route('/taskComments/:_id', function() {
var item = Tasks.findOne(this.params._id);
this.render('commentList', {data: item});
},
{
name: 'taskComments',
fastRender: true
}
);
aiutanti Template:
Template.commentList.helpers({
comments: function(){
return Comments.find({taskID: this._id});
});
sono in grado di accedere l'id del task (this._id) nel frammento di cui sopra, ma non sembra funzionare per onCreated:
Template.commentList.onCreated(function(){
this.subscribe("comments",this._id);
});
Quando ho consolo il login questo mi dà il seguente oggetto:
Si noti che non vi è _id e anche i dati sono nulli.