Object doesn't support this property or method undefined in IE8 on call to indexOf defined array [duplicate]

StackOverflow https://stackoverflow.com/questions/20624545

Domanda

I have a site built in AngularJS that has been working brilliantly. Unfortunately, our client requires the use of IE8. Everything seems to work fine in the site on IE8, except for the fact that I'm getting an object doesn't support this property or methodundefined. I spent all afternoon trying to figure out where the issue was, and I seem to have stumbled upon this bit of code, with the conditional of the if statement seemingly causing the issue:

var i = 0, len = $scope.data.length;
        for (; i < len; i++)
        {
            if ($scope.availableFilters.indexOf($scope.data[i].category) == -1)
            {

When I log out the variables, $scope.availableFilters is an empty array, $scope.data.category is a string, but when I log the indexOf call, it seems to throw the error, and not display the log I put after the log of the indexOf call.

Does anyone know why this would be? Is this saying that indexOf isn't defined? How could that be?

È stato utile?

Soluzione

It does not work because it is not supported in that version of IE.

Here is a polyfill that can be used

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top