sudodoki aka Джон, просто Джон

Front-end developer. Bad cook. Boy.


Published:
In angular | ui-router

ui.router: absolutely@nothing

Absolutely adressing views in angular-ui-router.

Something not many people had to leverage while working with ui-router is its ability to use absolute/relative addressing.
Behind the scenes every ui-view gets assigned absolute path. You can easily find source for figuring out '@'-name for view by randomly poking around code or stepping over debugger (that happened in my case).
This minor thing might come off handy some day when you're dealing with irregular outlet structure or different view hierarhies, that are supposed to be sharing same views.
In my case it was a task of having sidebar, which could have 2 different possible configurations & hierarchies – depending on different parts of the app – with state specific widget embedded into it. Naming my ui-view plug@sidebar in different outlets & addressing those in my state definition object worked like a charm.
It might be a bit risky relying on internal API, so don't forget to have tests for that & have proper dependency management. 😸

comments powered by Disqus