2

次のコードがあります。

var entityResource = $resource('/api/' + $scope.entityType + '/');

entityResource.delete(entityId,
   function (result) {
      $scope.remove($scope.grid.data, idColumn, entityId);
   }, function (result) {
      alert("Error: " + result);
   })

コードが実行されると、次のメッセージが表示されます。

DELETE http://127.0.0.1:81/api/Subject 404 (Not Found) 

{"message":"No HTTP resource was found that matches the request URI 'http://127.0.0.1:81/api/Subject'.","messageDetail

$resource が /api/Subject/123 で DELETE を送信するようにするにはどうすればよいですか? 現在、entityId の値を無視しているようです

アドバイスを受けてこれまでに試したことは次のとおりです。

    var entityResource = $resource('/api/:entityType/:entityId',
           { entityType: '@type', entityId: '@id' });
    entityResource.delete({ type: $scope.entityType, id: entityId }, 
        function (result) {
            $scope.remove($scope.grid.data, idColumn, entityId);
            $scope.remove($scope.grid.backup, idColumn, entityId);
            $scope.close();
        }, function (result) {
            alert("Error: " + result);
        })

残念ながら、これは私に与えます: DELETE /api?id=12&type=Subject HTTP/1.1

4

1 に答える 1