Skip to content Skip to sidebar Skip to footer

Reuse `ui-route` Controller That Expects A `resolve`d Parameter

I want to be able to reuse my ui-router-wired controllers. They currently receive parameters from ui-router resolve to render their templates. Can I reuse those controllers without

Solution 1:

In my case, which is a similar though limited subcase, I had multiple ui-router routes with resolve() defined, and only one place with the controller instantiated in a template via ng-controller, and the value passed to the controller in such case was a known, constant value.

In such case, you can simply do

.value('detailData', 'here goes the default/fallback value')

If you have multiple usages of ng-controller which should have different detailData, you need to find a better solution obviously.

Post a Comment for "Reuse `ui-route` Controller That Expects A `resolve`d Parameter"