AngularJS fail to load module

后端 未结 6 1621
南方客
南方客 2021-01-04 04:43

EDIT: This only happens with IE (tested on IE10)

I have a app that loads fine initially, however, when refreshed it gives this error:

SCRIPT50

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-04 05:14

    I felt like and idiot when I found what I was doing wrong, but in case you're like me, then here are some other things to check first:

    1. Make sure the child module is loading first. In my case, I had to make sure that the child module was physically before my parent module. You can confirm this by putting a breakpoint on each module init line.
    2. Even with correct physical order, the execute order was still off. One of my modules was wrapped in a self-executing function, and the other was not. Doh.
    3. There was an error in the child function which actually caused this error to show twice in the console. This is because I use a syntax like this:

      var mod = angular.module("blah", []);
      mod.filter("filterName", function(){ ... }); 
      

      At one point I forgot the empty brackets when starting the module, so the line looked like this and threw this error:

      var mod = angular.module("blah");  // <-- wrong
      

    To recap, make sure the child module executes first and has no errors.

提交回复
热议问题