Showing posts with label AngularJS. Show all posts
Showing posts with label AngularJS. Show all posts

Angular2 vs Angular4

Angular 2 and Angular 4 Doesn’t have much differences, it’s just an update for the features that are existed in angular2.

Angular2
Angular4 / Just Angular
Angular2 application size is larger when compared to angular4. Angular4 application is smaller and faster when compared to angular2 app.
*ngIf is not build with if/else syntax *ngIf has if/else syntax that make sense when you are making ajax calls we can show loading within the page.
For changing a text to title case, we need to write our own logic. Angular 4 has introduced a  new ‘titlecase’ pipe for converting first letter of each word to uppercase
Ex: <h1>{{‘hello world’ | titlecase}}</h1>
For creating templates we need to use template property New directive ng-template has introduced.
For animations need to import multiple packages and apply transactions For animations we now have own package @angular/platform-browser/animations

AngularJs 1 (vs) AngularJs 2

First thing to be clear is AngularJs 2is not an upgrade of Angular, it is completely different from Angular Js 1


Angular JS 1.X
Angular 2
Setting up application is very easy, need to just add the reference of angular.js Setting up application is quite complex, and it takes lot of work because it’s dependent on Gulp or Grunt.
Angular JS is not built with mobile support in mind. Whereas Angular2 was built for specially taking care of mobile support, so it’s mobile oriented.
Angular JS core concept was $scope, without scope we can’t communicate between views and controller. Angular2 is using Zone.js for detecting changes made in the DOM.
For communicating with views/templates it require controllers. It’s build with components.
Template Directives + controllers =    components
Performance is less when compared to angular2. Unidirectional tree based change detection increases its performance. As per ng-conf angular 2 is five times faster than angular1.
Angular1.X has ES5, ES6 and Dart Whereas angular2 has more choice, it can use any of the languages from ES5, ES6, and typescript/dart.
Ng-repeat is used for iterating through list of objects. Structural directives syntax is completely changed. Ng-repeat is replaced with *ngFor
Mostly built-in directives are used for events and element properties. Ex: ng-src, ng-href, ng-click etc. It directly uses the HTML DOM element properties. Ex: (click)
Ng-bind is used for one-way binding Whereas ng-bind is replaced with [property], where property is HTML DOM element property.
It has two ways to bootstrap the application, one is automatic bootstrapping (ng-app) and manual bootstrapping. It has only one way which is manual bootstrapping.
For routing it uses $routeProvider.when() It uses @RouteConfig {{…}}

What is AngularJS?

AngularJS is an open source web application framework. It was originally developed in 2009 by Misko Hevery and Adam Abrons. It is now maintained by Google. Its latest version is 1.4.3.


Definition of AngularJS as per documentation is as follows 


AngularJS is a structural framework for dynamic web apps. It lets you use HTML as your template language and lets you extend HTML's syntax to express your application's components clearly and succinctly. Angular's data binding and dependency injection eliminate much of the code you currently have to write. And it all happens within the browser, making it an ideal partner with any server technology.

Advantages of  AngularJS


1. AngularJS is a powerful JavaScript based development framework to create SPA (single page application).
2. AngularJS provides developers options to write client side application and it uses MVC framework.
3. AngularJS is cross-browser compliant.
4. AngularJS is open source, completely free, and used by thousands of developers around the world.





Core Features


Data-binding - It  automatically synchronizes data between model and view components.

Scope − These are objects that refer to the model. They act as a glue between controller and view.

Controller − These are JavaScript functions that are bound to a particular scope.

Services − AngularJS come with several built-in services for example $http to make a 
XMLHttpRequests. These are singleton objects which are instantiated only once in app.

Filters − These select a subset of items from an array and returns a new array.

Directives − Directives are markers on DOM elements (such as elements, attributes, css, and more). These can be used to create custom HTML tags that serve as new, custom widgets. AngularJS has built-in directives (ngBind, ngModel...)

Templates − These are the rendered view with information from the controller and model. These can be a single file (like index.html) or multiple views in one page using "partials".

Routing − It is concept of switching views.

Model View Whatever − MVC is a design pattern for dividing an application into different parts (called Model, View and Controller), each with distinct responsibilities. AngularJS does not implement MVC in the traditional sense, but rather something closer to MVVM (Model-View-ViewModel). The Angular JS team refers it humorously as Model View Whatever.

Deep Linking − Deep linking allows you to encode the state of application in the URL so that it can be bookmarked. The application can then be restored from the URL to the same state.

Dependency Injection − AngularJS has a built-in dependency injection subsystem that helps the developer by making the application easier to develop, understand, and test.


The AngularJS Components

The AngularJS framework can be divided into following three major parts

ng-app − This directive defines and links an AngularJS application to HTML.

ng-model − This directive binds the values of AngularJS application data to HTML input controls.

ng-bind − This directive binds the AngularJS Application data to HTML tags.