2013-03-21 69 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. 
    });