Monday, July 27, 2015

ngRoute - AngularJS Routing

Using the following code you can create a menu and title of a webpage using angular js. Please check the following code. Using the following code you can change the url. templateUrl helps to redirect the link.

var ueModule=angular.module('ueApp', ['ngRoute','ngSanitize'])
 .config( ['$routeProvider', function($routeProvider) {
  $routeProvider
   .when('/', {
    title: 'Home page',
    templateUrl: 'home.html',
    controller: 'widgetsController',
          activetab: 'home'  
   }) 
   .when('/about', {
    templateUrl: 'about.html',
    title : 'About us',
    controller: 'widgetsController',
          activetab: 'about'
   })
   .when('/values',{
    templateUrl: 'values.html',
    title : 'Values',
    controller: 'widgetsController',
          activetab: 'values'
   })
   .when('/partners',{
    templateUrl: 'partners.html',
    title : 'Partners',
    controller: 'widgetsController',
          activetab: 'partners'
   })
   .when('/people',{
    templateUrl: 'people.html',
    title : 'People',
    controller: 'widgetsController',
          activetab: 'people'
   })
   .when('/contact',{
    templateUrl: 'contact.html',
    title : 'Contact',
    controller: 'widgetsController',
          activetab: 'contact'
   })
   
   .otherwise({
    redirectTo: '/', templateUrl:'home.html',
   
   });
   
 }]);

0 comments: