I'm planning to use AngularJS in my big applications. So I'm in the process to find out the right modules to use.
What is the difference between ngRoute (angular-route.js) and ui-router (angular-ui-router.js) modules?
In many articles when ngRoute is used, route is configured with $routeProvider. However, when used with ui-router, route is configured with $stateProvider and $urlRouterProvider.
Which module should I use for better manageability and extensibility?
ngRoute is a module built by the Angular team that provides basic client-side routing functionality. This module provides a fairly powerful base for routing, and can be built upon pretty easily to give solid routing functionality, as exemplified in this blog post (be sure to read the comment trail between Ward Bell and Ben Nadel, the author - they are a couple of Angular pros)
ui-router shifts the focus from url-centric routes to application "states", which may or may not be reflected in the url.
The primary features added by ui-router are nested states and named views.
Nested states allow you to separate controller logic for the various pieces of the application. A very simple example of this would be an app with primary navigation across the top, a secondary navigation list along the left, and content on the right. Without nested states, a single controller would typically have to handle the display logic for the secondary navigation as well as the content. Nested routing allows you to separate these concerns.
Named views are another additional feature of ui-router. With ngRoute, you can only have a single ngView directive on a page, whereas with named views in ui-router you can specify multiple ui-view directives, and then each state is able to affect the template and controller of the names views. A super simple example of this would be to have the main content of your app be the primary view, and then to also have a footer bar that would be a separate ui-view. In this scenario, the footer's controller no longer has to listen for state/route changes.
A good comparison of ngRoute and ui-router can be found on this podcast episode.
Just to make things more confusing, keep an eye on the new "official" routing module that the Angular team is expecting to release for versions 1.5 and 2.0 of Angular. This will be replacing the ngRoute module. Here is the current documentation for the new Router module - it is fairly sparse as of this posting since the implementation has not yet been finalized. Watch here for more news on when this module will actually be released.
Basic thing you have to know: ng-router uses
$location.path()
and ui-router uses$state.go
Rest us all features.
ngRoute is a module developed by the AngularJS team which was earlier part of the AngularJS core.
ui-router is a framework which was made outside the AngularJS project to improve and enhance routing capabilities.
From the ui-router documentation:
Neither of them is better, you will have to chose the most appropriate for your project.
However, if you plan to have complex views in your application and you would like to deal with the "$state" notion. I recommend you to chose ui-router.
ngRoute is a module developed by the Angular.js team which was earlier part of the Angular core.
ui-router is a framework which was made outside the Angular.js project to improve and enhance routing capabalities.
URL: https://docs.angularjs.org/api/ngRoute
URL: https://github.com/angular-ui/ui-router
Some of the difference between ui-router and ngRoute
http://www.amasik.com/angularjs-ngroute-vs-ui-router/
1- ngRoute is developed by angular team whereas ui-router is a 3rd party module. 2- ngRoute implements routing based on the route URL whereas ui-router implements routing based on the state of the application. 3- ui-router provides everything that the ng-route provides plus some additional features like nested states and multiple named views.