AngularJS Architecture: Using ui-router's named views

InstructorLukas Ruebbelke

Share this video with your friends

Send Tweet

We'll take a deeper look at ui-router as we introduce named views into Eggly. We will take the basic state that we defined in the previous video and refactor it so that it consists of two unique views within the application.

James
~ 10 years ago

So, I get that a lot of people wonder how to handle sub views and the like in angular, but is this not what directives and transclusion are for? I know that for many people directives are the 'hardest' part of angular to learn but as a teaching resource would it be better to point people to directives as a solution to their problem?

Im just curious about the decision process for using ui-router for this feature? (Its better then ng-route just because of the ui-serf function but Im not sold on named views).

Nice demo though :) Keep up the good work.

Joel Hooks
~ 9 years ago

ui-routers #1 flaw IMO is the debugging. It fails silently providing no context for debugging. If a view is specified, but no matching target is found, it doesn't say a word!

These errors are almost always a missing ui-view or there is a string with a typo someplace.

Regardless, it is impossible to debug this without the code in context!

Guillaume Leclerc
~ 9 years ago

Question. I have almost the same setup, a main app with submodules, I use ui.router in all the submodules. But I couldn't make it work initially, I had a loading module error from Angular. I was able to solve it by putting ui.router as the first dependency in the main module. But I don't understand why it works. If I put my submodules first and ui.router after in the main module, then I have to redefine the ui.router dependency in my submodules. If I put ui.router first, then I don't need. I'm surprised. I'm sure I'm missing something simple here, any idea? Thanks!

Paul Mark Quinn
~ 9 years ago

It was bizarre for me in that, it would only work after I actually removed abstract and url from the base module state config:

.config(function ($stateProvider, $urlRouterProvider) { $stateProvider .state('eggly', { //url : '/', //abstract : true }) ;

  $urlRouterProvider.otherwise('/');

})

~ 8 years ago

Good call. Same situation here. The commenting out worked.

Aaron Endsley
~ 8 years ago

Im getting an injector error saying $urlRouteProvider

Aaron Endsley
~ 8 years ago

Ha Ha Never Mind I Mistyped its supposed to be $urlRouterProvider