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.

  1. var app = angular.module("AngularApp", ['ngRoute']);
  2. app.config(['$routeProvider', function($routeProvider)
  3. {
  4. $routeProvider. when('/page1', templateUrl: 'Modules/Page1/page1.html', controller: 'Page1Controller' }) .
  5. when('/page2', {templateUrl: 'Modules/Page2/page2.html', controller: 'Page2Controller' }) .
  6. otherwise ({ redirectTo: '/page1' });
  7. }
  8. ]);

results matching ""

    No results matching ""