Switching between views on same controller

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!

Answers


Consider useing ui-router:

UI-Router for Nested Routing by the AngularUI Team!

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


Need Your Help

How to print from the Thermal Printer in Android?

java android escaping point-of-sale thermal-printer

I am working on an application for an Android device that will have a built in line printer. I have to interact with this printer and use it to print the details on receipt and then with cutter cut...

Php: does "static" behaves like C?

php optimization

I have a "main class" that generates a db access. Something like: