Introduction
Angular is a platform to develop Web and mobile applications. Angular 2 is not just an update of Angular 1.x but Angular 2.0 is re-written and has many breaking changes. It is completely written in typed script (to meet ES 6 specifications). There will be a huge learning curve for the developers of Angular 2.
Difference between Angular 1.x and Angular 2.0

No Controller and $Scope
Angular 1.x is required to create a Controller and $scope. Both no longer exist in Angular 2.0. Angular 1.x’s Controller is replaced with the component in Angular 2.0.
Angular 1.x
- varmyApp = angular.module("myApp", [])
- .controller("empController", function($scope) {
- $scope.name = "Jignesh Trivedi";
- });
- import { Component } from 'angular2/core';
- @Component({
- selector: 'mydata',
- template: `
- <h3>{{name}}</h3> `
- })
- export class ProductComponent {
- name = "Jignesh Trivedi;
- }
Way of Bootstraping Angular Application is changed
Angular 1.x has two ways to bootstrap Angular.
- Using directive ng-app.
- Using Angular.bootstrap function.
Angular 2.0 has only one way to bootstrap Angular Application, using the bootstrap function.
- import { bootstrap } from 'angular2/platform/browser';
- import { TestComponent } from './Test.component';
- bootstrap(TestComponent);
ng-repeat directive is now replaced by *ngFor. ng-If is replaced with *ngIF. Angular 2.0. Camel Case syntax and Asterisk (*) sign is used as a prefix for the structural directives.
Angular 1.x
- <ul>
- <li ng-repeat="name in memberNames">
- {{name}}
- </li>
- </ul>
- <div ng-if="memberNames.length">
- <h3>You have {{memberNames.length}} Members.</h3>
- </div>
- <ul>
- <li *ngFor="let name of memberNames">
- {{name}}
- </li>
- </ul>
- <div *ngIf="memberNames.length">
- <h3>You have {{memberNames.length}} Members.</h3>
- </div>
Built-in directives syntax is changed
Angular 2.0 uses Camel case syntax for built-in directives. For example, ng-class is replaced with ngClass, ng-model is replaced with ngModel etc.
Event Syntax is changed
Angular 2.0 directly uses the valid HTML DOM element events. For example, ng-click is now replaced with (click)
Angular 1.x
- <button ng-click="clickEvent()">
- <button (click)="clickEvent()">
Angular 2.0 directly uses the valid HTML DOM element properties. Due to these changes, many built-in directives of Angular 1.x are now no longer required. For example, ng-href, ng-src, ng-show and ng-hide is no longer required. Angular 2.0 use href, src and hidden instead of ng-href, ng-src, ng-show and ng-hide directive.
One way data binding directive replaced with [property]
ng-bind directive is used for one way binding in Angular 1.x. Angular 2.0 uses HTML DOM element property for one way binding.
Angular 1.x
- <input type="text" ng-bind="name"></input>
- <input type="text" [value]="name"></input>
Two way data binding: ng-model replaced with [(ngModel)]
ng-model directive is used for two way data binding in Angular 1.x, but it is replaced with [(ngModel)] in Angular 2.0.
Angular 1.x
- <input type="text" ng-model="name"></input>
- <input type="text" [(ngModel)] ="name"></input>
There are five different ways to define the Service in Angular 1.x.
- Service
- Factory
- Constant
- Provider
- Values
Angular 2.0 has only one way to define the Service.
- import { Injectable } from 'angular2/core';
- @Injectable()
- export class DataService {
- constructor(public http: Http) {
- this.http = http;
- }
- getTestData() {
- return this.http.get("/api/Home/GetTestData")
- .map((responseData) =>responseData.json());
- }
- }
Way of routing is Changed- syntax changed
$routeProvider is used to configure routing and ng-view is used to load the view in Angular 1.x. In Angular 2, these are replaced with @RouteConfig and <router-outlet>respectively.
Angular 1.x
- var app = angular
- .module("MyModule", ["ngRoute"])
- .config(function ($routeProvider) {
- $routeProvider
- .when("/home", { templateUrl: "home.html", controller: "homeController" })
- })
- .controller("homeController", function ($scope) {
- $scope.message = "This is Home Page";
- })
- <ul>
- <li><a ng-href="#page4">Home</a></li>
- </ul>
- import { Component } from 'angular2/core';
- import { RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS } from 'angular2/router';
- @Component({
- selector: 'my-app',
- templateUrl: 'app/app.component.html',
- directives: [ROUTER_DIRECTIVES],
- providers: [
- ROUTER_PROVIDERS
- ]
- })
- @RouteConfig([
- { path: '/home', name: 'Home', component: HomeComponent, useAsDefault: true },
- ])
- export class AppComponent { }
- <ul>
- <li><a [routerLink]="['Home']" href="">Home</a></li>
- </ul>
Angular 2.0 supports TypeScript as development language whereas Angular 1.x is not supporting TypeScript.
Summary
Angular 2.0 is completely different from Angular 1.x. It requires some effort to migrate from Angular 1.x to Angular 2.0. Angular 2.0 implements web standards, for example, component, and it provides better performance than Angular 1.x.

Vinod AbrahamPosted Sep 24, 2017, 1:13 AM
Very valuable stuffs
Kunal VaishyaPosted Sep 17, 2016, 4:04 AM
Nice Article
Vivek KumarPosted Aug 10, 2016, 4:19 AM
Nicely explained.
Lakshmanan Sethu SankaranarayanPosted Jul 18, 2016, 1:31 AM
Good one
Sanjay SabariyaPosted Jul 8, 2016, 12:32 AM
Thanks for sharing knowledge.
Naveen BishtPosted Jul 1, 2016, 2:54 AM
Hi very nice...
Anupam SinghPosted Jun 30, 2016, 5:44 AM
Thanks for sharing buddy, well written.. everything in one place..
Ravi PatelPosted Jun 30, 2016, 5:17 AM
Nice
Shantha Kumar TPosted Jun 30, 2016, 1:27 AM
Thanks for the article
Santhakumar MunuswamyPosted Jun 30, 2016, 12:58 AM
Thank you for nice article
Jignesh TrivediPosted Jun 29, 2016, 6:03 AM
Thank you all for reading my article.
kalu singh raoPosted Jun 29, 2016, 1:27 AM
Nice one...
Guest UserPosted Jun 28, 2016, 11:05 PM
Cool. i enjoyed reading this article. Ang2.0 differs a lot than 1.0
Kuppurasu NagarajPosted Jun 28, 2016, 2:12 PM
Nice Sharing..
Debasis SahaPosted Jun 28, 2016, 11:42 AM
Nice share