AngularJS provides a simple and concise way to associate routes with controllers and templates using the $routeProvider . Having recently updated the application to the latest version (1.2 RC1 at the current time), I realized that $routeProvider no longer available in the standard angular.js script.
After reading the change log, I realized that routing is now a separate module (it seems to me a big move), as well as animation and some others. As a result, standard module definitions and a configuration code, such as the following, will work more if you upgrade to version 1.2 (or future):
var app = angular.module('customersApp', []); app.config(function ($routeProvider) { $routeProvider.when('/', { controller: 'customersController', templateUrl: '/app/views/customers.html' }); });
How do you fix it?
Just add angular -route.js in addition to angular.js to your page (take the version of angular -route.js here - keep in mind the current version of the candidate release that will be updated) and change the module definition as follows:
var app = angular.module('customersApp', ['ngRoute']);
If you use animations, you will need angular -animation.js, and you also need to reference the appropriate module:
var app = angular.module('customersApp', ['ngRoute', 'ngAnimate']);
Your code may be as follows:
var app = angular.module('app', ['ngRoute']); app.config(function($routeProvider) { $routeProvider .when('/controllerone', { controller: 'friendDetails', templateUrl: 'controller3.html' }, { controller: 'friendsName', templateUrl: 'controller3.html' } ) .when('/controllerTwo', { controller: 'simpleControoller', templateUrl: 'views.html' }) .when('/controllerThree', { controller: 'simpleControoller', templateUrl: 'view2.html' }) .otherwise({ redirectTo: '/' }); });