如何让Angularjs $http.delete和asp.net mvc4最小化一起工作



我正在开发一个AngularJs/asp.net mvc4应用程序,它通过asp.net mvc web api与后端通信。

javascript文件的缩小是用mvc4完成的,但是当我在angular代码中使用$http.delete时,mvc4缩小器在捆绑的文件中返回以下错误:

/* Minification failed. Returning unminified contents.
(1029,11-17): run-time warning JS1010: Expected identifier: delete
(1029,11-17): run-time error JS1137: 'delete' is a new reserved word and should not be used as an identifier: delete

我已经做了一个替代保留词的解决方案(在本例中为'delete'),在这里描述,https://stackoverflow.com/a/13418911/1029874

这意味着$http.delete将被$http.fooDelete取代,导致角不再识别它。

是否有另一个解决方案或使用jQuery ajax代替最简单的解决方案?

@larchii使用$http'delete'正如@stewie提到的。正如本文所述,使用任何IE保留字都会导致抛出预期的标识符错误。还有一个指向IE保留词列表的链接。

我也有同样的问题,但我的解决办法是这样做,而不是使用快捷键:

$http({method: 'DELETE', url: '/someUrl'}).
  success(function(data, status, headers, config) {
    // this callback will be called asynchronously
    // when the response is available
  }).
  error(function(data, status, headers, config) {
    // called asynchronously if an error occurs
    // or server returns response with an error status.
  });

最新更新