Answer the question
In order to leave comments, you need to log in
Can't access $rootScope from another controller in angularjs.TypeError: $rootScope.get_groups is not a function?
I create the $rootScope.get_groups() function in one control.
Then I try to call this function from another controller, but it says
TypeError: $rootScope.get_groups is not a function
Why is it not read from $rootScope?
It seems that when the 2nd controller accesses this function, it does not seem to exist yet.
Answer the question
In order to leave comments, you need to log in
it's simple, if you inject a scope into a controller, you're doing something wrong. You need a common functionality - take it out to services. If you limit yourself and allow the use of scope only in the link function of directives, then life will become much more pleasant. $rootScope, for declaring which global shortcuts, in principle, it is permissible to pull, but also somehow not very cool. Usually only for events.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question