Â
AngularJS provides a simple and concise way to associate routes with controllers and templates using a $routeProvider object. While recently updating an application to the latest release (1.2 RC1 at the current time) I realized that $routeProvider isnât available in the standard angular.js script any longer. After reading through the change log I realized that routing is now a separate module (a great move I think) as well as animation and a few others. As a result, standard module definitions and config code like the following wonât work any longer if youâre moving to the 1.2 (or future) release:
Â
var app = angular.module('customersApp', []); app.config(function ($routeProvider) { $routeProvider.when('/', { controller: 'customersController', templateUrl: '/app/views/customers.html' });
});
How do you fix it? Simply add angular-route.js in addition to angular.js to your page (grab a version of angular-route.js here â keep in mind itâs currently a release candidate version which will be updated) and change the module definition to look like the following:
Â
var app = angular.module('customersApp', ['ngRoute']);
Â
If youâre using animations youâll need angular-animation.js and also need to reference the appropriate module:
Â
var app = angular.module('customersApp', ['ngRoute', 'ngAnimate']);
Â
Check out the change log for additional details on changes to animations. Touch is also a separate module now.
I like the move to a more modular architecture since not all apps may need routing, animations, and some of the other stand-alone modules. It allows the framework to grow over time without the core script getting too big.
If youâre interested in keeping up-to-speed with all things related to AngularJS, subscribe to the AngularJS Magazine (a FlipBoard magazine that can be viewed through a browser or through the application).
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4