Using angular ui-router I'm trying to make nested routing based on condition.i.e Want to check a 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',
})
basically the nested router main.home.default
must be loaded conditionally
if(something){
//loaded state main.home.default
}
How can I achieve this?