Introduction to Angular
Welcome to the Angular Tutorial. we will create an application at the end of this tutorial. we are writing this tutorial at the time of Angular 14 release.
What is Angular?
Angular is a UI Framework which is used to create Desktop and Mobile web Application. Angular is built using JavaScript. The Angular is an open-source and helps us build dynamic & single-page applications (SPAs). With Angular you can create client-side application using HTML, CSS and TypeScript.
Key differences between AngularJs & Angular
1. Controller and components
In AngularJs we have controllers but in Angular we have component in place of controller. In Angular, a component represents a UI element. You can have any number of components on a single web page. Each component is independent of each other and manages a section of the page. The components can have child components and parent components.
2. Directives
Syntax of Directive is different in Angular as compared to AngularJs. Angular has a * before the directive name indicating it as a structural directive.
Example
AngularJs : ng-if
Angular : *ngIf
3. Angular data bindings is same with minor syntax changes.
Interpolation
AngularJS
<h3>{{controllerAlias.user.Name}}</h3>
Angular
<h3> {{user.Name}}</h3>
we used controller alias to specify the controller instance in AngularJS. In Angular, the context is implied.
One way Binding
AngularJS
<h3> ng-bind=controllerAlias.user.name></h3>
Angular
<h3 [innerText]=”user.name” ></h3>
Event Binding
AngularJS
<button ng-click=”controllerAlias.save()”>Save<button>
Angular
<button (click)=”save()”>Save<button>
The AngularJS uses the ngClick directive to bind to the event. In Angular ngClick Directive is removed. You can bind directly to the DOM events.
Two- way binding
AngularJS
<input ng-model=”controllerAlias.user.name”>
Angular
<input [(ng-model)]=”user.name”>
4. $scopes are not present in Angular
The Angular is using zone.js to detect changes.
5. Bootstrap
In AngularJs we use ng-app directive in our HTML file then the angular would bootstrap and attach the ng-app
Angular is written in TypeScript and it meets ECMAScript 6 specification, it means it has support for ES6 class framework, modules etc.
Comments
Post a Comment