Reputation: 185
$http.delete('/api/carts/' + productCode).
success(function() {
cart.products = someMethod();
updateTotals();
}).
error(function() {
console.log('Could not remove product from card: ' + productCode);
});
IE8 complains that "expected identifier" on the first line. The code works fine in Firefox, Chrome, etc.
Upvotes: 15
Views: 4954
Reputation: 738
$http.delete(path)
is a shortcut for DELETE
requests.
So as the shortcut breaks on IE8, besides calling by their uglly form: $http['delete']
, you can call using the original mode:
$http({method: 'DELETE', url: path})
Upvotes: 3
Reputation: 7688
delete is the JavaScript reserved keyword, and IE parse it as a keyword. Here is the solution. http://tech.pro/tutorial/1238/angularjs-and-ie8-gotcha-http-delete
Here is the javascript reserved keyword list
http://www.w3schools.com/js/js_reserved.asp
so its better to use $http['delete']
instead of $http.delete
Upvotes: 2
Reputation: 4771
The problem is that delete
is a javascript keyword and IE8 parses it slightly incorrectly. According to the standard, identifiers can be called delete
. A quick fix is:
$http['delete']('/api/carts/' + productCode)
A little ugly, and I don't think the good angular people should have named that method delete, but that fixes your problem
Upvotes: 23