Introduction to ui-router

InstructorJoel Hooks

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
~ 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 Hooksinstructor
~ 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
~ 8 years ago

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

Joel Hooksinstructor
~ 3 years ago

That’s a great tip 👍