I would like to return the .state(\'name\') when I change location in angular.
From my run() it can return the $state object:
As an alternative to Sandeep's solution, you can also do it this way:
angular.module('yourApp').run(['$rootScope', '$state',
function ($rootScope, $state) {
$rootScope.$state = $state;
}
]);
Doing it this way, it only gets set once instead of on every stateChange. Basically you just store a reference to $state somewhere - I chose $rootScope just to keep this example simple.
Now in my code I can easily reference it like:
and
Current State: {{$state.current.name}}
I also generally store $stateParams as well so I have even more information about the state (but I left it out of this example).