UrbanPro
true

Learn Angular.JS from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Angular 1 vs Angular 2

Shibaji Debnath
13/02/2018 0 0

Angular 1 vs Angular 2

Angular team has released the angular 2, which has drastically change the way programmers interact and work with Angular framework in the past. In this post I will tell you the common changes made by the team in the current release. The primary goal of latest Angular 2  is to create an easier and more powerful web framework. Angular 2 is initially made with TypeScript, but this will be compatible with all latest JavaScript standards like ES5 and ES6 and Dart-lang.

New Component-Based Architecture

Angular 2 is based on component based architecture. Old Controllers and $scope systems is replaced with components and directives. Now controllers and directives are most important part of AngularJS based applications. Components work with selectors. A component has a selector and associated html tag to represent it.

Differences of Representation in Angular 1 and Angular 2:

Angular 1.x:

angular.module(‘myApp’,[])
.controller(‘TestCtrl”, function() {
});

 

Angular 2.0:
import {Component, View} from 'angular2/angular2';
@Component({
 
selector: 'my-view'
 
});

 

 

At bootstrap we have to declare components before we start working with them. These components have to be imported on the page where these are used.

Input with the Event Syntax:

Angular 2 makes events processing more simplified.  Now applications can respond to input as an event too. You can deal with input like an event. The event syntax is simple as now you can denote events within parenthesis.

Differences of User Input handling syntax in Angular 1 and Angular 2:

Angular 1.x:

 
 

Angular 2.0:

 
 

Better Performance:

Angular 2 is both faster and more memory efficient than Angular 1 this is done with the help of immutable data structures. Another reason for improved performance is introduction of uni-directional data flow. There is no direct way to implement two way data flow in angular 2 . This concept is in fact implemented in an entirely different way in Angular 2. You can use export syntax to do the same.

Data flow in Angular 2:

@View({
templateUrl: './components/example/example.html'
})

export class Example {} 
 

No $scope in Angular 2:

Although $scope variable was an important part of angular 1 but it is deprecated in angular 2.

But the main thing to consideration is even ‘$scope’ is deprecated it is in fact is replaced by “controller”. In angular 2 properties are bound to components itself to work in applications.

Angular 2 is more transparent due to Zones:

Angular 2 uses the zones mechanism. This ensures that old digest cycle is not necessary in the new environment. Angular 2 digest, if triggered by a component that is inside a zone:

Directives:

With a clean Directive annotation you can declare a directive in application. Directives can be used in components.

Improved Dependency Injection:

Angular 2 has a better and improved dependency injection system. There are much more opportunities for components based applications.

There are certain benefits other benefits of AngularJS. Element references can also be available to other parts of the template. Angular team has taken a  nice step to launch angular 2.

0 Dislike
Follow 2

Please Enter a comment

Submit

Other Lessons for You

Git Branching: Basic Branching And Merging
Basic Branching and Merging: Let’s go through a simple example of branching and merging with a workflow that you might use in the real world. You’ll follow these steps: Do work on...

JavaScript Arrow Function.
Javascript Arrow Functions : JavaScript ES6 is a type or version which let us provide a way to write javascript syntax on a better way. ES6 version is having a feature or new method to use functions...

Inversion of Control
Problem You have classes that have dependencies on services or components whose concrete type is specified at design time. In this example, ClassA has dependencies on ServiceA and ServiceB. Figure 1 illustrates...

JavaScript Arrow Function
Javascript Arrow Functions : JavaScript ES6 is a type or version which let us provide a way to write javascript syntax in a better way. ES6 version is having a feature or new method to use functions...
A

Abhay

0 1
0

NgModules vs. JavaScript modules (Angular 2)
The NgModule — a class decorated with @NgModule Decorator — is a fundamental feature of Angular. JavaScript also has its own module system for managing collections of JavaScript objects. It's...
X

Looking for Angular.JS Classes?

The best tutors for Angular.JS Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Angular.JS with the Best Tutors

The best Tutors for Angular.JS Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more