user4002542
user4002542

Reputation:

One controller and more than one template with ui-router?

I'm trying to figure out if i need register three states for just one controller.

I have this errors templates: 404.template.html, 505.template.html and feature.template.html

Currently i'm registering with ui-router only the feature.template.html, and i am associating the controller with him. What about the other two? Should i register and associate the same controller?

For example:

$stareProvider
  .state({
    url: '/error',
    templateUrl: '/admin/error/feature.template.html',
    controller: 'ErrorController',
    controllerAs: 'ctrl'
  });

What about the other two: 404.template.html and 505.template.html?

Thanks.

Upvotes: 0

Views: 39

Answers (1)

Icycool
Icycool

Reputation: 7179

You can always assign same controllers to different states or directives. If I remember correctly, they will also be instantiated separately so their scope variable is not shared among each other.

Upvotes: 1

Related Questions