Search code examples
angularjsinternet-explorer-11handsontable

Angular 1.4.8 incompatible with IE11 - Object doesn't support property or method 'endsWith'


How can I get this JSFiddle using HAndsOnTable and Angular 1.4.8 to work with IE11? I get this error:

Object doesn't support property or method 'endsWith'

I'm not sure but I think the culprit is this line:

$scope.$apply();

Solution

  • I fixed your fiddle and I also fixed the IE11 error. Please not that .endWith() is not a valid function in IE. Once you added this function as a prototype you will be fine:

    if (!String.prototype.endsWith) {
      String.prototype.endsWith = function(searchString, position) {
          var subjectString = this.toString();
          if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) {
            position = subjectString.length;
          }
          position -= searchString.length;
          var lastIndex = subjectString.indexOf(searchString, position);
          return lastIndex !== -1 && lastIndex === position;
      };
    }
    

    (taken from https://www.sitepoint.com/community/t/endswith-issue-in-ie11/233838)