2017-07-07 10 views
1

私は$ onサービスを使用して私のコントローラに渡したい2つのフィールドを持っています。 これは、今、私が他のコントローラに両方の変数を渡す必要が最初の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); 
} 

答えて

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); 
      } 
+0

それは感謝を働いた.. :) – ashworx

+0

あなたは歓迎しています! –

関連する問題