What is the role of the $routeProvider in AngularJS?
Instruction: Explain how the $routeProvider is used to configure routes in an AngularJS application.
Context: This question tests the candidate's understanding of AngularJS's routing mechanism, a key concept for creating single-page applications (SPAs).
Updated
Official answer available
Read the opening below, then unlock the full answer and practical guidance.
$routeProvider configures routes for the optional ngRoute module during AngularJS module configuration. It is distinct from the runtime $route service, which tracks the active route and performs transitions.
Load angular-route alongside the matching AngularJS version, include ngRoute as a module dependency, and inject $routeProvider using a minification-safe annotation in a config block. Use when(path, definition) for route entries and otherwise for the fallback behavior. An ng-view outlet hosts the selected content...