Thursday, June 14, 2018

Angular 2 Vs Angular Js

Angular 1.x was not built with the  mobile support. where Angular 2 is mobile oriented.

Angular 2 is Type Script.


AngularJS 1.x is very easy to set up. All you need to do is to add reference of the library. Where Angular 2 is dependent of other libraries and it requires some efforts to set up it.


Angular 1.x controllers and $scope are gone. We can say that controllers are replaced with “Components” in Angular 2. Angular 2 is component based.Components are the building blocks of angular application.


Structural directives syntax is changed. ng-repeat is replaced with *ngFor.


In Angular 2, local variables should declare using hash(#) .


To filter output in our templates in Angular 1.x, we use the pipe character (|) and one or more filters. Where in Angular 2 they are called pipes. The syntax remains same.


Angular 2 uses camelCase syntax for built-in directives. For example, ng-class is now ngClassand ng-model is now ngModel.


D Between AngularJS(v1.x.x) and Angular (v2.x.x or above)


Javascript  to   Type Script

ng-app to BootStrap
Filters pipe to Filter pipes
Controller to Component
Angular 1.x, two-way data binding

<input ng-model="employee.name"></input>


In Angular 2,


<input [(ngModel)]="employee.name"></input>



One of the biggest advantage of Angular Js is Dependency Injection. In Angular 2 Dependency Injection is achieved using Constructor.



In Angular 1.x, we can define a service via 5 different ways.


Factory

Service
Provider
Constant
Values


In Angular 2 we can define using Class


ng-view present in Angular 1.x is replaced with <router-outlet>


In Angular 1.x, we use $routeProvider.when() to configuring routing. Where in Angular 2, @RouteConfig{(...}) is used. ng-view present in Angular 1.x is replaced with <router-outlet>


Performance wise Angular 2 is more better.


With Angular 2 we can built single application which will work in both desktop and mobile applications. 


Angular 2 Languages:


ECMA Script 5

Type Script
ECMA Script 6

No comments:

Post a Comment

Thank you for visiting my blog

Kubernetes

Prerequisites We assume anyone who wants to understand Kubernetes should have an understating of how the Docker works, how the Docker images...