2013-05-13 18 views
0

我正在創建一個消息服務,需要執行以下操作1.)從我們的消息服務中加載消息,獲取收件人的ID,然後從中加載收件人的信息一項用戶服務。我已經嘗試使用消息服務回調,並且還在消息對象上創建了一個觀察器,但沒有取得太大的成功。該服務工作,但它不會正確地將結果分配給$範圍。這是控制器。所有的服務都在正常工作。

function MessageCtrl ($scope, $http, $location, $routeParams, Messages, Members) { 
    if ($routeParams.mid) { // Checks for the id of the message in the route. Otherwise, creates a new message. 
     $scope.mid = $routeParams.mid; 
     $scope.message = Messages.messages({mid: $scope.mid}).query(); 

     $scope.$watch("message", function (newVal, oldVal, scope) { 
      if (newVal.data) { 

       $scope.recipients = Members.members({uids: newVal.data[0].uids}).query(); 
      } 
     }, true); 

    } else { 
     $scope.create = true; 
    } 

    // Events 

    $scope.save = function() { }; 
    $scope.preview = function() { }; 
    $scope.send = function() { }; 
} 

回答

相關問題