Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Difference between Angular 1.x and Angular 2.0

    • 0
    • 0
    • 0
    • 0
    • 1
    • 0
    • 0
    • 0
    • 1.21k
    Comment on it

    Angular 2 is different from Angular 1 as it is written completely in Typescript and includes the ES6 specification. As it is not updated version of Angular 1.x so it is rewritten and has many changes.

    Component based Programming:
    Angular2 is component based programming language like ReactJs. Component create faster entities that are less dependent. We can say that controllers of angular1 are replaced with Components in Angular2. In Angular1 there is modular programming concept.

    Angular 1.x Controller
     

    var myApp = angular
       .module("myModule", [])
       .controller("productController", function($scope) {
         var prods = { name: "Prod1", quantity: 1 };
         $scope.products = prods;
    });

    Angular 2 Components using TypeScript
     

    import { Component } from 'angular2/core';
     
    @Component({
      selector: 'prodsdata',
      template: `
        <h3>{{prods.name}}</h3> `
    })
     
    export class ProductComponent {
      prods = {  name: 'Prod1', quantity: 1 };
    }


    No $Scope in Angular 2:
    In Angular2 there is no use of $scope to communicate between view and controller.

    function($scope)
    {
    $scope.comparison =Angular 1 vs Angular 2
    }
    //is replaced by
    constructor()
    {
    this.comparison =Angular 1 vs Angular 2
    }

    Bootstrap:
    In Angular2, there is no use ng-app to bootstrap. It can be done via the code:

    import { bootstrap } from 'angular2/platform/browser';
    import { ProductComponent } from './product.component';
     
    bootstrap(ProductComponent);

    In Angular1 there are two ways to bootstrap. It can be using ng-app or by code:
     

    <script>
       angular.element(document).ready(function() {
          angular.bootstrap(document, ['myApp']);
       });
    </script>

     

    TypeScript:
    Angular2 is totally based on TypeScript. Other languages like ReactJs are also using TypeScript. It is very good to learn. In Angular1 there is not any concept of TypeScript.

    Mobile Support:
    Angular2 has mobile oriented architecture while in angular1 there was no mobile support and it supported two way data binding and responsive application.

    Performance improvements:
    Angular2 is faster than Angular1 in performance. In angular2 bootstrap used is specific to platform.

     

 1 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: