javascriptangularjsiifeangular-controller

AngularJS controller prepended by a ? In Chrome


Occasionally when I update some code in my controller and then check it in chrome it will throw a controller not registered error and also a syntax error. When I look at the chrome source files the controller in question will have a “?” prepended to it. It won’t go away with a hard reset either.

In the past to fix the error I have added ? marks to the beginning of it and then hard refreshed until the chrome source file updated. However today that did not work so I removed the IIFE the controller was wrapped in and hard refreshed and that worked. I actually think the IIFE isn’t useful for this controller because it’s used like below but I’m not 100% sure.

   (function (){
   angular.controller(“controllerName”, [“dependencies”,
function (dependencies) { 
    $scope.code = 1;
    }])
   )();

Sorry for the bad formatting I’m on my phone...

Thus never really touching the global scope, so I removed it from the IIFE and then updated and it finally worked without the ? mark prepend being present.

Thanks for any help or tips.

However, I’m wondering what can cause this error. We only use chrome so other browsers are not a problem if it is browser related.


Solution

  • The problem was because the code was being shared with people off shores. They were using a different character set than UTF-8 on their keyboard!