Webnet Webnet - 1 year ago 107
AngularJS Question

How can I programmatically/dynamically change the view?

I'd like to have a "wizard" of sorts where the screen changes a few times during the process. I'd like to utiilze Angular's controllers for this. I can't however, figure out how to change the view that's being displayed programmatically.

It doesn't look like there's any kind of

I can define.

Answer Source

You are going to want to learn about ngView => http://code.angularjs.org/1.1.4/docs/api/ng.directive:ngView

This way you can use $route to configure the display of partial content. You will want to declare the template option like:

$routeProvider.when('/path', {
  templateUrl: '/path/to/my/view.htm',

Another option is to use ngSwitch => http://code.angularjs.org/1.1.4/docs/api/ng.directive:ngSwitch

For a wizard I would think that ngSwitch is less efficient but will be the easier of the two. This does sound like what you are looking for though.

"The ngSwitch directive is used to conditionally swap DOM structure on your template based on a scope expression."

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download