Subscribe do not working with router.current().params


#1

Dear all,

I am getting problems when I try to get an object from a collection, the subscribe function are not working as expected. For Example:

Client:

JS

Template.Main.onCreated(function(){
var num = Router.current().params.taskid;
console.log(num);
this.subscribe(‘getTransaction’,num);
});

Server:

Meteor.publish(‘getTransaction’, function(taskid){
return Transactions.find({taskid:taskid});
});

If I keep this as it is I cannot show anything, the value showed in the console is 9. However if I change the variable “num” for the explicit value: 9 it works as expected.

Do you know why the subcribe is not working on this case?

I really appreciate all your help about it.


#2

It looks like this is the same question as your other post - I’ve answered it there: