2013-03-21 73 views
3

我正在研究一个通过asp.net mvc web api与后端进行通信的AngularJs/asp.net mvc4应用程序。

的JavaScript文件的缩小与mvc4做,但是当我在角码使用$http.delete的mvc4 minifyer中捆绑的文件返回以下错误:

/* 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 

我已经做了变通方法,代替保留字(在这种情况下“删除”),在此所说明,https://stackoverflow.com/a/13418911/1029874

这意味着$http.delete将与$http.fooDelete被替换,从而该角不任何更多识别它。

是否有另一种解决方法或是最简单的解决方案来使用jQuery ajax?

+4

使用'$ HTTP [“删除”()',并尽量不要使用jQuery阿贾克斯曾经同时在AngularJS中。 – Stewie 2013-03-21 08:43:44

回答

1

@larchii使用$ http'delete'作为@stewie提到的。根据this article,使用任何IE保留字会导致预期的标识符错误被抛出。还有一个指向IE保留字列表的链接。希望这可以帮助。

0

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

$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. 
    });