Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angularjs $http.delete breaks on ie8

$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.

like image 776
eggplantbr Avatar asked Oct 21 '14 04:10

eggplantbr


1 Answers

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

like image 96
triggerNZ Avatar answered Sep 27 '22 21:09

triggerNZ