When my app starts, the following code is executed:
$urlRouterProvider.otherwise('/loading');
This leads to the control being passed to my loadCtrl
. Inside this controller, I have the following code snippet:
Service.getRoleDetails(config.USER_DETAILS_URL).then(useRoleDetails, handleApiError);
function useRoleDetails(response) {
if (response.id === 1) {
$state.go('home');
}
else
$state.go('master');
}
function handleApiError(error) {
Overlay.applyOverlay(false);
}
The service call and callback function are working correctly. The conditions inside the `if` statement are met, but for some reason, the state does not change to home
. My screen remains stuck on the initial page (which is the template for `/loading').
I have never encountered such an issue with $state
before. Am I missing something? Even though there are no console errors.
Any suggestions?
Here is my configuration:
$stateProvider.state('preload', {
url: '/loading',
views: {
"main": {
controller: 'landingPageCtrl as lc',
templateUrl: 'PP/htmls/landing.tpl.html'
}
},
data: {
pageTitle: 'PricingPlan'
}
})
.state('home', {
url: '/pricingplan',
views: {
"main": {
controller: 'PPCtrl as pp',
templateUrl: 'PP/htmls/pricing-position.tpl.html'
}
},
data: {
pageTitle: 'Pricing Plan'
}
})
.state('master', {
url: '/master',
views: {
"main": {
controller: 'masterDataCtrl as mdc',
templateUrl: 'PP/htmls/MasterData/masterData.tpl.html'
}
},
data: {
pageTitle: 'Master Data'
}
})
.state('logout',{
url: '/loggedOut',
views: {
"main": {
controller: 'logOutCtrl as lc',
templateUrl: 'PP/htmls/logout.tpl.html'
}
},
data: {
pageTitle: 'Session Expired'
}
});
}