我有两个字段,我想使用$ on service传递给我的控制器。 这是第一个js
$scope.submitFilterForm = function(query){
var query='test';
var deviceType= filterStateService.getActiveFilterState();
messageBus.send(Message.SubmitFilterForm,query,deviceType);
}
现在我必须将两个变量传递给其他控制器。其他控制器中的查询正确,但设备类型未定义。 我的问题是我们可以传递多个参数。
$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);
}
答案 0 :(得分:1)
你可以传递一个对象:
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);
}