Skip to main content

Upgrading from Angular 1.0 to 1.2

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
  1. 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>
  2. Add Route Module - Add the “ngRoute” module to your controller code base

    var myApp = angular.module('myApp', ['ngRoute']);
    
    
  3. Replace "then" with "success" for your Ajax calls

    BeforeAfter


    var url = 'someWCFcall';
              $http.get(url)
                    .then(function (data) {
       //Some awesome code
                    });
    var url = 'someWCFcall';
              $http.get(url)
                    .success(function (data) {
       //Some awesome code
                    });


  4. Repeat step 3 until you don’t have any more web service calls with “.then”
  5.  Misc. item
    1.  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. 
  6.  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

Popular posts from this blog

Turning WCF Service into .asmx for debugging

Even though .asmx web services are becoming dinosaurs of the new .NET world of WCF. I missed the simplicity of debugging code right in visual studio without: Creating a client to consume WCF service Attaching w3p.exe process and Adding break points  One quick solution: Turn WCF service into .asmx service with few lines of code, debug your code with asmx, and turn .asmx off during deployment.  Detail steps: 1- First take your WCF class and add WebService attribute to it Code Snippet /// <summary> /// Dual mode with .ASMX and WCF /// </summary> [ WebService (Namespace = "http://www.yourdomain.com/" )] 2- Then add WebMethod attribute to a function you want to expose in .asmx Code Snippet [ WebMethod ] public List < PageController . Page > DualFunction() { 3- Take the .svc file from your solution - copy and rename the copied file [YourOriginalWCFFile.asmx]. Open up the copied file and rename "ServiceHost...

Processing ASP MVC Web API Requests in Multi-threaded JS Web Worker

Unlike an asynchronous Ajax call, HTML5 Web workers provide an opportunity to run a Multi-threaded JavaScript code in modern browsers that support them . Each worker spawns an isolated thread with dedicated JavaScript Event Loop, Stack and Heap memory. For example a regular Ajax Call to MVC Web API service call goes through the following asynchronous call cycle. The JavaScript Event Loop in this case could be interrupted by events that are being executed on the UI; for instance, a "window.alert", could possibly stop all scripts on the page from executing until a user responds. Replacing the Ajax Call with HTML5 web worker provides a great way to run long running scripts in separate threads so that asynchronous code execution is not interrupted by UI events. Here is the a JavaScript worker implementation of the same MVC Web API call using a JavaScript web worker. Despite the advantages of using a web worker, implementing one requires working with some constr...

ASP.MVC Real-time data processing with Sharded RavenDB and SignalR

In a move that some call "Radical” The Weather Channel recently swapped their enterprise Oracle and MySql Databases for NoSQL  MongoDB .  One word that could describe the rapid adoption of NoSQL databases compared to relational once is “ sharding .” Unlike relational databases, NoSQL systems allow developers to be active participants in the data storage process by providing a way to create logic (sharding strategy) that outlines how and where data could be stored, resulting in better scalability and improved performance. RavenDB , an open source NoSQL system for .NET that is easy to deploy (both as a standalone/embedded system) for an ASP.MVC application. SingalR is a tool that one can use in a .NET environment to add real-time client-server processing in an application. SignalR allows a developer to broadcast messages to all (or some) clients from a centralized client and/or server call. I was looking for a quick data-sharding example with embedded Rave...