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...
Why not write rootScope into run?