Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Angular 2 vs Angular 1

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.54k
    Comment on it

    As in my previous post I have already explained that AngularJS1 is a javascript library which is prefect for single page application(SAPs). Angular js is nothing just a javascript library which extends HTML with new markups. Single page application are those web application which will load a single web page and dynamically call other pages when user interacts with application.

    Where as AngularJS2 is the updated version of AngularJS1 in which there are n number of changes are done by Google and the angular contributors to make better framework by lowering the learning curve and providing performance enhancements.

    What are the differences?

    Component Based UI:

    As we all know AngularJS has a component UI based , a concept that might be familiar to React developers. In angularJS 1.x we will use controller and directives which will become blur into the new Angular 2 component.Its mean that we will not more use controller and directives in AngularJS 2.In Angular 2  a component has a selector which corresponds to the html tag that the component will represent and a @View to specify an HTML template for the component to populate.

    Here is the example how Angular 1.x and Angular 2.x has worked .

    Angular 1.x:

    angular.module(myFirstApp)
    	.controller(myFirstAppCtrl, function() {
    });
    

    Angular 2.0:

    import {Component, View} from 'angular2/angular2';
    
    @Component({
      selector: 'myFirstApp'
    })
    
    @View({
      templateUrl: './components/example/example.html'
    })
    
    export class Example {}
    
    Goodbye $scope

    In angular 1 we will use $scope to defining and accessing data but In angular 2 $scope is finished.Here is the example of this.

    Angular 1.x:

    angular.module(example)
         .controller(ExampleCtrl, function($scope) {
             $scope.name = John Smith;
    });

     

    Angular 2.x:

    @Component({
         selector: 'example'
    })
    
    @View({
      templateUrl: './components/example/example.html'
    })
    
    export class Example {
          constructor() {
              this.name = John Smith;
          }
    }
    

     

    Better Performance:

    AngularJS 2 is much powerful and fast as compare to Angular1.

    These all are the differences between Angular1.x and Angular2

 0 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: