0

I have this little piece of JavaScript code in my angular project that throws a syntax error when running in IE 11 but works fine in Chrome. This function isn't even invoked on the loading page but the error is still thrown.

If I comment it out the page loads fine.

It seems to be complaining about the .then line, and I have no idea why.

$scope.showNewTeamDialog = function (ev) {
        $mdDialog.show({
            controller: NewTeamDialogController,
            templateUrl: 'NewTeam.html',
            locals: { newTeamName: $scope.newTeamName },
            parent: angular.element(document.body),
            targetEvent: ev
        }).then((newTeamName) => {
            if (newTeamName != undefined) {
                $scope.newTeamName = newTeamName.newTeamName;
                $scope.createNewTeam();
            }
        });

    };
halfer
  • 19,824
  • 17
  • 99
  • 186
David
  • 1,203
  • 6
  • 25
  • 48

1 Answers1

2

You will have to modify your code to support IE.

$scope.showNewTeamDialog = function (ev) {
        $mdDialog.show({
            controller: NewTeamDialogController,
            templateUrl: 'NewTeam.html',
            locals: { newTeamName: $scope.newTeamName },
            parent: angular.element(document.body),
            targetEvent: ev
        }).then(function(newTeamName){
            if (newTeamName != undefined) {
                $scope.newTeamName = newTeamName.newTeamName;
                $scope.createNewTeam();
            }
        }.bind(this);
    };

IE doesn't support the syntax you have written. Use function syntax instead of arrow syntax.

MattjeS
  • 1,367
  • 18
  • 35
Vijay Rathore
  • 593
  • 8
  • 16