search

Home  >  Q&A  >  body text

angular.js - When $rootScope is called in the scope of ngView, it often cannot be called because the root scope is slow to load.

Now the program can run, but sometimes it needs to be refreshed several times to get it right. If you are unlucky, it will appear when loading

TypeError: $rootScope.gotoPGoals is not a function

and other error messages. It is speculated that there is a competition between the loading speed of the root scope and the current scope. If the root scope cannot catch up with the loading completion, the call will fail.
Wondering how to fix this problem?


Cannot be written in app.run(), because functions such as $scope.gotoPGoals() are defined in the controller of the directive and operate the $element of the directive.
Because the directive and the superior (that is, ngView) share the same scope, it is called with $rootScope...

阿神阿神2835 days ago645

reply all(1)I'll reply

  • 仅有的幸福

    仅有的幸福2017-05-15 16:56:06

    Why not write rootScope into run?

    reply
    0
  • Cancelreply