Advantages of angularjs 2 over angular 1

The main differences and advantages on Angular2 vs. Angular 1 as following:

  1. It is entirely component based: The earlier version of Angular had a focus of Controllers but now has changed the focus to having components over controllers.
    Angular 1:
    var app = angular.module("userApp", []);
    app.controller("userController", function($scope) {
       $scope.users = [{ name: "sathish", Age:30}, { name: "ram", Age:33}];
    Angular 2:
    Here the @Component annotation is used to add the metadata to the class.
    import { Component } from 'angular2/core';
      selector: 'usersdata',
      template: '<h3>{{}}</h3gt;' 
    export class UsersComponent { users = [{ name: "sathish", Age:30}, { name: "ram", Age:33 }]; }
  2. Better change detection.
  3. Better performance
  4. More powerful template system.
  5. Provide simpler APIs, lazy loading and easier to application debugging.
  6. More testable.
  7. Provides to nested level components.
  8. AOT (Ahead of Time compilation) improves rendering speed
  9. Execute run more than two programs at the same time.
  10. The Angular2 structural directives syntax is changed like ng-repeat is replaced with *ngFor etc.
    Angular 1
    <div ng-repeat="role in roles">
    Name: {{}}, Description : {{role.description}}, Status: {{role.status}}
    <div *ngFor="let role of roles">
    Name: {{}}, Description : {{role.description}}, Status: {{role.status}}
  11. In Angular2, local variables are defined using prefix (#) hash. You can see the below *ngFor loop Example.
  12. TypeScript − The newer version of Angular is based on TypeScript. This is a superset of JavaScript and is maintained by Microsoft.
  13. Better syntax and application structure
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkedin
Share On Pinterest

Be the first to comment

Leave a Reply

Your email address will not be published.