I have a main state which is reached by accessing the URL http://myapp/validate.
Upon reaching this URL, inside the controller I do a permission check, and redirect the user to one of the two child states.
This works, 80% satisfied, but uses some resources and causes a small flicker in my app, since basically I load a view I DO NOT USE.
Is there a better way to achieve this?
Any ideas?
angular.module('app.validate').config(['$stateProvider', function($stateProvider) {
$stateProvider
.state('validate', {
url: '/validate',
template: '<ui-view/>',
controller: ['$state', 'HasPermission', function ($state, HasPermission) {
// Here is where I do my logic.
if (HasPermission.get('can-lock-as-admin')) {
$state.go('validate.lock-as-admin');
}
if (HasPermission.get('can-lock-as-clerk')) {
$state.go('validate.lock-as-clerk');
}
}]
})
.state('validate.lock-as-admin', {
templateUrl: 'theUrl',
controller: 'ValidateLockAdminCtrl'
})
.state('validate.lock-as-clerk', {
templateUrl: 'theUrl',
controller: 'ValidateLockClerkCtrl'
})
.state('validate.commit', {
templateUrl: 'theUrl',
controller: 'ValidateCommitCtrl'
});
}]);
template: '<ui-view/>',as rendering this empty view may be causing the flicker. - Nitin...