Implementing nested ui-router resolves
As you gain experience as an AngularJS developer, you will come to realize that the built-in router faculties are quite brittle in a number of ways—mainly that there can only be a single instance of ng-view
for dynamic route templating. AngularUI provides a superb solution to this in ui-router
, which allows nested states and views, named views, piecewise routing, and nested resolves.
How to do it…
The ui-router
framework supports resolves for states in the same way that ngRoute
does for routes. Suppose your application displayed individual widget pages that list the features each widget has, as well as individual pages for each widget's features.
State promise inheritance
Since nested states can be defined with relative state routing, you might encounter the scenario where the URL parameters are only available within the state in which they are defined. For this application, the child state has a need to use the widgetId
and the featureId
value in the child...