Using built-in AngularJS routing services

The AngularJS framework has a built-in $route service that can be configured to handle route transitions in single-page web applications. It covers all the features that we were trying to handcraft using the $location service and additionally offers other very useful facilities. We are going to get familiar with those step-by-step.

Note

Starting from Version 1.2, AngularJS will have its routing system delivered in a separate file (angular-route.js) with its own module (ngRoute). When working with the latest version of AngularJS, you will need to remember to include the angular-route.js file and declare a dependency on the ngRoute module.

Basic routes definition

Before diving into more advanced usage scenarios, ...

Get Mastering Web Application Development with AngularJS now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.