One of the projects I recently worked on required an upgrade from Angular 1.0 to 1.2. The upgrade was not a result of Angular 1.0 limitations (in terms business needs), version 1.0 works just fine; however, Angular 1.0 is an experimental release and chances of running into already known and less desirable issues was very likely without moving to a stable version of Angular. Here are the steps that I took to rewrite the application JS functions to work with Angular 1.2.
Caveat: Folks at Angular have migration guideline documentation here - http://docs.angularjs.org/guide/migration - the steps I outlined below only deal with updates to a specific application (Angular 1.0 running with WCF web services), you might want to review the migration guideline document if you run into any issues after your application upgrade.
Steps
Caveat: Folks at Angular have migration guideline documentation here - http://docs.angularjs.org/guide/migration - the steps I outlined below only deal with updates to a specific application (Angular 1.0 running with WCF web services), you might want to review the migration guideline document if you run into any issues after your application upgrade.
Steps
- Take the plunge – remove references to Angular 1.0 and replace them with Angular 1.2. You will need two JS references for Angular instead of one.
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.10/angular.min.js"></script> <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.10/angular-route.min.js"></script>
- Add Route Module - Add the “ngRoute” module to your controller code base
var myApp = angular.module('myApp', ['ngRoute']);
- Replace "then" with "success" for your Ajax calls
Before After var url = 'someWCFcall'; $http.get(url) .
then(function (data) { //Some awesome code });var url = 'someWCFcall'; $http.get(url) .success(function (data) { //Some awesome code });
- Repeat step 3 until you don’t have any more web service calls with “.then”
- Misc. item
- Images – If you have images that are returned from an Angular Ajax call, you can only use “src” or “ng-src” (not both) to bind them to an image element.
In my case, the steps above were enough to upgrade Angular. If you run into any issues after the updates refer to the complete Angular migration document.
Comments