How to add routing:-
The $routeProvider definition contained by the module is called "ngRoute". In app.js file, I have defined an angular app using “angular. Module” method. After creating module, we need to configure the routes. The "config" method is used to configure $routeProvider. Using "when" and "otherwise" method of $routeProvider, we can define the route for our AngularJS application.
- var app = angular.module("AngularApp", ['ngRoute']);
- app.config(['$routeProvider', function($routeProvider)
- {
- $routeProvider. when('/page1', templateUrl: 'Modules/Page1/page1.html', controller: 'Page1Controller' }) .
- when('/page2', {templateUrl: 'Modules/Page2/page2.html', controller: 'Page2Controller' }) .
- otherwise ({ redirectTo: '/page1' });
- }
- ]);