我有以下代码:
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