Asp.net mvc 4 如何使Angularjs$http.delete和asp.net mvc4缩小协同工作?
我正在开发一个AngularJs/asp.net mvc4应用程序,它通过asp.net mvc web api与后端进行通信 javascript文件的缩小是通过mvc4完成的,但是当我在angular code中使用Asp.net mvc 4 如何使Angularjs$http.delete和asp.net mvc4缩小协同工作?,asp.net-mvc-4,angularjs,bundling-and-minification,Asp.net Mvc 4,Angularjs,Bundling And Minification,我正在开发一个AngularJs/asp.net mvc4应用程序,它通过asp.net mvc web api与后端进行通信 javascript文件的缩小是通过mvc4完成的,但是当我在angular code中使用$http.delete时,mvc4缩小器在捆绑文件中返回以下错误: /* Minification failed. Returning unminified contents. (1029,11-17): run-time warning JS1010: Expected id
$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”)的变通方法,如下所述
这意味着$http.delete
将替换为$http.fooDelete
,导致angular不再识别它
使用jQuery ajax还有其他解决方法吗?或者是最简单的解决方案吗?@larchii使用@stewie提到的$http'delete'。根据,使用任何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.
});
在AngularJS中使用$http['delete']()
,尽量不要使用jQuery ajax。