I am currently using angular's ui-router to implement nested routing based on a specific condition. I need to check this condition before loading a state.
.state('main.home', {
url: "/:cnt",
abstract: true,
templateUrl: function ($stateParams) {
return template1;
},
controller: "myController",
resolve: {
//Some model
}],
lazy: ['$ocLazyLoad', '$stateParams', function ($ocLazyLoad, $stateParams) {
//lazily loaded controllers
}]
},
onEnter: updateAppValues,
}).state('main.home.default', {
url: '',
templateUrl: function ($stateParams) {
return template2;
},
resolve: {
lazy: ['$ocLazyLoad', function ($ocLazyLoad) {
//lazily loaded controllers
}]
},
controller: 'myDefaultController',
})
In essence, I require the nested router main.home.default
to be loaded only if a specific condition is met.
if(something){
//load state main.home.default
}
Could you please guide me on how to accomplish this?