Configuring the routes

We can configure the routing mechanism of our application with the $routeProvider function. This can be done by adding each route through the when function, which maps the URL pattern to a configuration object. This object has the following information.

PropertyDescription
<applicationName>This represents the module name of the application.
<viewName>This represent structure of the incoming request pattern.
config()This function configures the routing module for the incoming request.
controllerThis is the name of the controller that should be associated with the template
templateUrlThis is the URL of the template that will be rendered by the ngView module
resolveThis is the map of dependencies that should be resolved and injected inside the controller (optional)
redirectToThis is the redirected location
when/ otherwiseThese are the associated clauses to redirect the request to the targeted HTML view.

Syntax
var myApplication = angular.module("", ["ngRoute"]);
myApplication.config(function($routeProvider) {
$routeProvider.when('/viewName1', {
templateUrl: '/partial1.html'
});
$routeProvider.when('/viewName2', {
templateUrl: '/partial2.html'
});
$routeProvider.otherwise({
redirectTo: '/viewName1'
});
});
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 # # # # #