1

Is there a way to have multiple otherwise statements. I basically have an otherwise method that redirects any unknown urls to the home page.

$urlRouterPro`vider.otherwise('/home');

However now I am trying to create a multi step form that will use nested states:

.state('accountsetup', {
  url: '/account-setup',
  templateUrl: 'app/views/multiforms/account-setup/setup.html',
  controller: 'AccountSetupCtrl'
})

.state('accountsetup.profile', {
  url: '/profile',
  templateUrl: 'app/views/multiforms/account-setup/profile.html'
})

.state('accountsetup.oncology', {
  url: '/oncology',
  templateUrl: 'app/views/multiforms/account-setup/oncology.html'
})

Of course I need the form to redirect to the /profile as it is the first view of the multi form. My thought was to add:

$urlRouterProvider.otherwise('/account-setup/profile');

Obviously this will only override the other. How do I go about achieving this behavior?

Thank you.

Aaron
  • 2,364
  • 2
  • 31
  • 56
  • Not at all clear what the redirect criteria is. – charlietfl Jun 19 '16 at 23:07
  • I have one redirect that redirects to the home page. But I have a nested ui view that is seen above for a multi step form. The first state is where the main form elements will live with the nested
    . That ui view will render the states responsible for the first and second step of the form process. I wanted to make sure that if /account-setup was ever entered into the url that template would not render, rather be redirected to /profile. I hope that clears it up.
    – Aaron Jun 19 '16 at 23:36
  • I have actually found a solution @ http://stackoverflow.com/questions/29491079/redirect-a-state-to-default-substate-with-ui-router-in-angularjs. Maybe you have a better one. Seems like a lot to do just to safeguard against something that will likely never happen. – Aaron Jun 19 '16 at 23:37
  • Use a resolve or stateChange event handler. Still not clear what purpose of the parent is. If it's an `abstract` state then configure it as abstract – charlietfl Jun 19 '16 at 23:39
  • The parent is the container for a step through form. After the user fills out the first form and selects submit the next form slides into position for the user to continue. The .profile is the first form view and the oncology is the second. – Aaron Jul 24 '16 at 16:08

0 Answers0