5

I am starting a new angular project(a single page app), which will have complex views (dialogs, wizards, popups, loaders), though exact requirements are not so clear at the moment.

Should I use ui.router upfront ? Or should I begin with ngRoute and change to ui.router when needed ?

What benefit ui.router has over ngRoute ? What are the limitations that may make me to opt for ui.router instead ?

From my research it seems ui.router does lot more than ngRoute, I would try to avoid the complexity as long as possible.

I read What is the difference between angular-route and angular-ui-router?, but doesnt really help (me being a total angular noob).

I have fine skills in js,jquery,html though.

3
  • Use ui-router upfront. It is just as easy in use as the built in ng-route but with the benefit that it has a lot more features that will come in handy down the road. (Resolving data before a view is rendered, adding custom data to a view... etc.) Commented Sep 11, 2015 at 12:30
  • but ngRoute provides all the same features for rendering, custom data, doesn't it ? Commented Sep 11, 2015 at 12:34
  • Oh it does. I think the linked in your thread sums up the extra features perfectly, especially the nested views are a big bonus of ui-router. Since you already know you're having complex views in your app, why would you opt to pick ng-route then? The learning curve? Which is exactly the same in ui-route imo. Commented Sep 11, 2015 at 12:42

2 Answers 2

3

I suggest go ahead with ui.router, why ?

  • its almost as complex as ngRoute

  • it will better allow you to use same view in a page, popup, or container within another page

  • more readable code

    /book/{{book.name}}/chapter/{{chapter.name}}

    vs

    book.chapter({chapter : chapter.name})

  • and you would observe the power of ui.router more, as you dive deeper into angular.

Trying to keep it simple, given you are an "angular noob" :-).

Sign up to request clarification or add additional context in comments.

3 Comments

That was really helpful, but will I have any limitation of ngRoute over ui.router ?
Nops, I don't see any (you need not worry).
instead, I had to do workarounds, for reusing views in a modal window in one of my recent assignment. And the solution wasn't as good as what I could have done with ui.router.
1

I'd recommend starting with uiRouter, it can do (almost) everything that ngRouter can do and a lot more (e.g. nested routes, views etc.). I think the only thing that ngRouter has, but uiRouter doesn't is optional URL parameters.

1 Comment

you know nothing about ui router (I realize you must get that a lot... still worth it). If you leave an uiRouter parameter empty it will happily carry on to the state but without a value for that param. You can even have them "out" of the URL: github.com/angular-ui/ui-router/wiki/…