To configure routes, we need to use the $routeProvider
function; this maps paths from the current URL to a route object. The route object can include a controller, an HTML template, and other properties (for more information, visit https://docs.angularjs.org/api/ngRoute/provider/$routeProvider). This recipe will show you how to lay the initial groundwork to begin testing your routing logic, such as mapped values, and assigning route parameters to scope.
Ensure that you have included the angular-route.js
file as documented in this chapter's introduction. You can use the following example code as a basis for testing in this recipe or use an existing application that includes ngRoute:
Load the ngRoute module in your application by adding it as a dependent module:
angular.module('chapter3.ngRoute', ['ngRoute'])
Add a
config
block that will get applied during the application's bootstrap process. Theconfig
block injects providers, so this...