I would like to do $state.reload()
in my angular application for debugging purpose. See this related question how-do-i-reload-an-angular-partial-for-testing-purpose
However, I am not able to capture the $state
in my application which doesn't even have the $rootScope
object exposed? I managed to get the $rootScope by doing this as shown in how-to-access-update-rootscope-from-outside-angular
var $body = angular.element(document.body);
var $rootScope = $body.scope().$root;
And then as explained in the Wiki
var myApp = angular.module('myApp', []);
angular.module("myApp").run(function ($rootScope, $state, $stateParams) {
$rootScope.$state = $state;
$rootScope.$stateParams = $stateParams;
});
But this not setting anything to $rootScope.$state
thought $rootScope is accessible now. Any help? I'm using Angular 1.3.x.
Edit: Even this doesn't work,
angular.module("myApp").run(function ($rootScope, $state, $stateParams) {
console.log("Testing");
});