2015-10-26 56 views
1

我定義了以下服務:但是

MyManager.findById(contractId, 
      // on success 
      function (response) { 
       // do 
      }, 
      // on error 
      function() { 
       alert("Error"); 
      }); 

的:

myServices.factory('MyManager', ['$resource', 
    function ($resource) { 
     return $resource('../rest/contract/:contractId', {contractId:'@contractId'}, { 
      findById: {method: 'GET', contractId: '@contractId'} 
     }); 
    }]); 

我想使REST調用,並在我的控制,我這樣做生成的URL是<base>/rest/contract,並且沒有附加路徑變量。我傳遞給findById的參數不爲null。

我在做什麼錯?

回答

3

你必須傳遞參數作爲對象:

MyManager.findById({contractId: contractId}, ...