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,471
  • 17
  • 87
  • 173
David
  • 1,153
  • 6
  • 20
  • 44

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,267
  • 21
  • 32
Vijay Rathore
  • 593
  • 9
  • 15