While using angular ui-router, I encountered an issue where the fromState
parameter was returning an empty object, while the toState
was functioning correctly. I am trying to access fromState.name
. This is how my controller looks:
.controller('MainCtrl', function ($rootScope) {
// State change start
$rootScope.$on('$stateChangeStart', function (event, toState, fromState){
console.log(fromState); // -> Object {url: "/program", templateUrl: "views/program.html", resolve: Object, name: "program"}
console.log(toState); // -> Object {} when clicking on e.g. 'news'
});
});