2016-05-13 9 views
1

を追加されていないサービスにPUTリクエストのURLは私のスクリプトです:角度JS - ここ

var shipResource = $resource('http://localhost\\:8083/consignments/:cId', null, {ship: {method: 'PUT'}}); 

$scope.shipConsignment = function() { 
    if($scope.selectedConsignment != null){ 
     var consignId = $scope.selectedConsignment.consignmentId; 
     console.log(consignId) //works fine 
     shipResource.ship({cId: "consignId"}); //not working? cId is not added to URL 
    } 
}; 

そしてHTML:

<button type="button" ng-click="shipConsignment()">Ship</button> 

つのサービス側、私はのためのPUT要求する機能を持っていますURL:localhost:8083/consignment/{consignmentId}

ただし、リクエストはlocalhost:8083/consignmentに送信されています。これは私に405メソッドが許可しないようにします。どんな助けもありがとう。

+0

私は方法を変更する場合:それはPUTのURLにconsinIdを追加ではなく、 'GET'。 –

+0

CORSの問題が見つかりました –

答えて

0

そして、これを試してみてください:

$resource('http://localhost\\:8083/consignments/:id', {Id: "@cId"}, {ship: {method: 'PUT'}}); 
+0

はい、\\はコロンをカプセル化します –