Search code examples
angularjsdebuggingangularjs-injector

Once I turn off debuggingData in angular, is there another way to get the rootscope?


I think having debugging info on by default in Angular will sink large apps. You can now disable this in production:

https://docs.angularjs.org/guide/production#disabling-debug-data

But there are some cases where I do:

angular.element(document).scope()

in order to access the rootScope. Is there another way in angular to get the $rootScope without this debugging feature on?


Solution

  • To access $rootScope you could do

    angular.element(document).injector().get('$rootScope')