-1

I've got a page that says "GENERATE", and it has a form on it. And then you submit the form by pressing the Generate button, and I want it to take you to a new view called "LOADING" whilst it waits for the result to come back from the server, then when the response comes back successfully I want it to take you to a "SHARE" page that allows you to share what you get back. This flow is all on 1 controller/route:

http://mydomain.com/create

At the moment my routes look like so:

.config(function ($routeProvider) {
$routeProvider
  .when('/', {
    templateUrl: 'views/main.html',
    controller: 'MainCtrl'
  })
  .when('/create', {
    templateUrl: 'views/create.html',
    controller: 'CreateCtrl'
  })
  .otherwise({
    redirectTo: '/'
  });

});

How can I do this view switching behavior, or what is the most recommended way to do it? If the response is an error I want to go back to the create page for example as well, so I need that sort of control.

Thank you!

b0xxed1n
  • 2,063
  • 5
  • 20
  • 30
  • don't need a new view for loading...just toggle a loading overlay when start request `ng-show="isLoading"` – charlietfl Dec 09 '13 at 05:36
  • Well I'll need a new view for the share page anyway, so the question still applies. Plus I'm not sure I like that way because then I'll need to hide other elements as well. Seems like it could get really messy. – b0xxed1n Dec 09 '13 at 05:40
  • overlay can cover whatever you want...and then if error, are right where you started which was part of your criteria... make changes on success – charlietfl Dec 09 '13 at 05:48

1 Answers1

1

Consider useing ui-router:

UI-Router for Nested Routing by the AngularUI Team!

Sample: http://angular-ui.github.io/ui-router/sample/

CD..
  • 72,281
  • 25
  • 154
  • 163