ashish.g
ashish.g

Reputation: 588

How to pass multiple parameters to $on service

I have two fields which I want to pass to my controller using $on service. This is first js

$scope.submitFilterForm = function(query){     
    var query='test';
    var deviceType= filterStateService.getActiveFilterState();
    messageBus.send(Message.SubmitFilterForm,query,deviceType);
}

Now I have to pass both variables to other controllers. A query is coming correct in other controller but Device type is coming as undefined. My question is can we pass multiple parameters.

$scope.$onMessage(Message.SubmitFilterForm,function(event,data,deviceType) {    
    console.log("Value of data n device type is",data);
    console.log("Value of data n device type is",deviceType);
}

Upvotes: 1

Views: 659

Answers (1)

Stanislav Lohtin
Stanislav Lohtin

Reputation: 81

you can pass an object:

messageBus.send(Message.SubmitFilterForm,{ query: query, deviceType: deviceType});

$scope.$onMessage(Message.SubmitFilterForm,function(event,data) {    
            console.log("Value of data n device type is",data.query);
            console.log("Value of data n device type is",data.deviceType);
            }

Upvotes: 1

Related Questions