I just a made a function for my app that checks the users info. I created this in my authentication controller in the $rootScope
My problem is that now, I have to manually call that function in all the controllers that I have.
There must be a way to automatically call that on all pages when the page loads.
Thanks!
Have a look at $location service.
After url changes it broadcasts '$locationChangeSuccess' so from there you can just use $scope.$on();
Ref. https://docs.angularjs.org/api/ng/service/$location
Update: After reading your comment you might be better of using .run
AngularJS app.run() documentation?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With