as pointed out by Aaron, you can use $ state to go to the default child state, but there is a catch here, suppose you have more than one child:
.state('places', { url:'/places', controller:'PlacesController', templateUrl:'views/places.html' }) .state('places.city', { url:'/:city', templateUrl:function(stateParams) { return 'views/places/'+stateParams.city+'.html'; } }) .state('places.child2', { url:'/:city2', templateUrl:function(stateParams) { return 'views/places/'+stateParams.child2+'.html'; } });
and in the parent controller PlacesController you have $ state.go (places.city) , then whenever the parent controller is called, i.e. PlacesController, you will be redirected to the city state, therefore, if someone is in child2 state and presses the update button, then the parent controller will be called and it will be redirected to the city that you do not need!
ANS:. Thus, you can check the current state before performing the redirection, that is, if the person is in the parent state, then the redirect to any child state by default, but if the person is in any of the child states, then do not redirect to the parent controller: -
if($state.current.name == "places"){ $state.go('places.city'); }
hope this helps!
Rishul matta
source share