I have states mentioned as
.state('login', {
url: '/login',
templateUrl: 'views/login.html',
controller: '',
ncyBreadcrumb: {label: 'Home'},
data: {freeRoute: true}
})
.state('dashboard', {
url: '/',
templateUrl: 'views/login.html',
controller: '',
ncyBreadcrumb: {label: 'Dashboard'},
data: {authenticatedRoute: true},
})
I wish to run configuration in case if page is refreshed, like this
.run(function ($rootScope, $state, $stateParams, AUTH_EVENTS, dataService) {
if ($state.$current.data.authenticatedRoute == true) {
console.log('Authenticated Route.');
if (dataService.isAuthenticated()) {
$rootScope.$broadcast(AUTH_EVENTS.alreadyAuthenticated);
} else {
$rootScope.$broadcast(AUTH_EVENTS.notAuthenticated);
}
} else {
console.log('Not Authenticated Route.');
}
});
But when I tried to log console on current state it gives me like this...
{"name":"","url":"^","views":null,"abstract":true}
-- How would I get current state. in controller? I have also tried console.log($state.$current);
-- How would I access in views as well, irrespective of controller?