Introduction to ui-router

Share this video with your friends

Send Tweet

In his debut egghead.io lesson, Joel will show you how to get setup and running with ui-router, an alternative to AngularJS's default routing module.

ryan
ryan
~ 10 years ago

Hi there,

Would #/list/Bread navigate straight to the bread section with the bread image already loaded (say this shopping list app was hosted online and from a fresh browser tab I enter listappname/list/Bread in the address bar).

Joel Hooks
Joel Hooks(instructor)
~ 10 years ago

Hey Ryan, it definitely should. Because "bread" is a parameter, the state should be contextually aware and load the appropriate state.

It's something that you have to consider in your controller and models. When you land in the state it should ask, "do I have the data? If yes, show, if no load".

One of the state config options is "resolve" that returns a promise to block the state from loading until the above is done, which can be useful for this type of logic.

Paul
Paul
~ 9 years ago

Instead of using ng-class to set the active view, try ui-sref-active-eq="active".

Joel Hooks
Joel Hooks(instructor)
~ 4 years ago

That’s a great tip 👍