I've a publication which relies on a client's parameter. Therefore, while subscribing from the client I need to send this parameter to the server. I'm using the angular-meteor package and found the $subscribe wrapper. The usage is as follow: $subscribe.subscribe(name, publisherArguments)
I am trying to pass dynamic $scope values to the subscription but it does not seems to work. For example the following example never alerts "You subscribed !"
$subscribe.subscribe('aPublication',$scope.parameter).then(function(){
alert("You subscribed !");
});
assuming the server side looks like this
Meteor.publish("aPublication", function (parameter) {
ACollection.find({'aProperty':'parameter'}) });
What should I do to make the $scope.parameter
works the same way as if I was using Session.get('parameter')
?
@Flavien Volken, that's a really nice solution but in our new 0.6.0 version you can also do it with a solution a bit more similar to the Meteor way using scope.getReactively - http://angularjs.meteor.com/api/getReactively
So in your solution:
$meteorUtils.autorun($scope, function() {
$meteorSubscribe.subscribe('aPublication',
$scope.getReactively('parameter'))
.then(function(){
alert("You subscribed !");
});
});
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments