Search code examples
javascriptangularjsinternet-explorerie-developer-tools

AngularJS code not executing InternetExplorer when Developer Tools are closed


Unfortunately I've stumbled upon a problem with my application. When running in Internet Explorer.

I earlier found that it could be related to a console.log problem, but there is no console.log anywhere in my code. However, when opening the console (F12 Developer Tools) the application runs as expected.

Could it be related to $parent.$on function?

 $scope.$parent.$on("updateCart", function (e) {
        shoppingCartService.getItems().then(function (d) {

                vm.items = d;

        });
    });

Solution

  • It cannot be related to that, and I'm fairly sure it is in fact console.log but in a place where you don't expect it.

    You can debug JavaScript without the developer console by alerting all errors:

    window.onerror = function(msg, url, linenumber) {
        alert('Error message: '+msg+'\nURL: '+url+'\nLine Number: '+linenumber);
        return true;
    }
    

    Or by including Firebug lite: https://getfirebug.com/firebuglite


    Update: if errors still don't show up, try overriding AngularJS's exception handler: (see also https://stackoverflow.com/a/25285528/451480)

    YOURAPP.factory('$exceptionHandler', function() {
      return function(exception, cause) {
        alert('Error message: '+exception.message+'\nURL: '+exception.fileName+'\nLine Number: '+exception.lineNumber+'\nCause: '+cause);
      };
    });