ANGULAR
Complete Angular Tutorial For Beginners Introduction to Angular | What is Angular? Architecture Overview & Concepts of Angular How to Install Angular How to Create a new project in Angular Bootstrapping in Angular: How It Works Internally Angular Components Overview & Examples Data Binding in Angular Interpolation in Angular Property Binding in Angular Event Binding in Angular ngModel & Two way Data binding in Angular NgModelChange & Change Event in Angular Child/Nested Components in Angular angular directives angular ngFor directive ngSwitch, ngSwitchcase, ngSwitchDefa ult Angular Example How to use ngIf, else, then in Angular By example NgClass Example Conditionally apply class Angular ngStyle Directive Angular Trackby to improve ngFor Performance How to Create & Use Custom Directive In Angular Working with Angular Pipes How to Create Custom Pipe in Angular Formatting Dates with Angular Date Pipe Using Angular Async Pipe with ngIf & ngFor angular keyValue pipe Using Angular Pipes in Components or Services Angular Component Communication & Sharing Data Angular Pass data to child component Angular Pass data from Child to parent component Component Life Cycle Hooks in Angular Angular ngOnInit And ngOnDestroy Life Cycle hook Angular ngOnChanges life Cycle Hook Angular ngDoCheck Life Cycle Hook Angular Forms Tutorial: Fundamentals & Concep t s Angular Template-driven forms example How to set value in template-driven forms in Angular Angular Reactive Forms Example Using Angular FormBuilder to build Forms SetValue & PatchValue in Angular StatusChanges in Angular Forms ValueChanges in Angular Forms FormControl in Angular FormGroup in Angular Angular FormArray Example Nested FormArray Example Add Form Fields Dynamically SetValue & PatchValue in FormArray Angular Select Options Example in Angular Introduction to Angular Services Introduction to Angular Dependency Injection Angular Injector, @Injectable & @Inject Angular Providers: useClass, useValue, useFactory & useExisting Injection Token in Angular How Dependency Injection & Resolution Works in Angular Angular Singleton Service ProvidedIn root, any & platform in Angular @Self, @SkipSelf & @Optional Decorators Angular '@Host Decorator in Angular ViewProviders in Angular Angular Reactive Forms Validation Custom Validator in Angular Reactive Form Custom Validator with Parameters in Angular Inject Service Into Validator in Angular template_driven_form_validation_in_angular Custom Validator in Template Driven Forms in Angular Angular Async Validator Example Cross Field or Multi Field Validation Angular How to add Validators Dynamically using SetValidators in Angular Angular HttpClient Tutorial & Example Angular HTTP GET Example using httpclient Angular HTTP POST Example URL Parameters, Query Parameters, httpparams in Angular HttpClient Angular HTTPHeaders Example Understanding HTTP Interceptors in Angular Angular Routing Tutorial with Example Location Strategy in Angular Angular Route Params Angular : Child Routes / Nested Route Query Parameters in Angular Angular Pass Data to Route: Dynamic/Static RouterLink, Navigate & NavigateByUrl to Navigate Routes RouterLinkActive in Angular Angular Router Events ActivatedRoute in Angular Angular Guards Tutorial Angular CanActivate Guard Example Angular CanActivateChild Example Angular CanDeactivate Guard Angular Resolve Guard Introduction to Angular Modules or ngModule Angular Routing between modules Angular Folder Structure Best Practices Guide to Lazy loading in Angular Angular Preloading Strategy Angular CanLoad Guard Example Ng-Content & Content Projection in Angular Angular @input, @output & EventEmitter Template Reference Variable in Angular ng-container in Angular How to use ng-template & TemplateRef in Angular How to Use ngTemplateOutlet in Angular '@Hostbinding and @Hostlistener_in_Angular Understanding ViewChild, ViewChildren &erylist in Angular ElementRef in Angular Renderer2 Example: Manipulating DOM in Angular ContentChild and ContentChildren in Angular AfterViewInit, AfterViewChecked, AfterContentInit & AfterContentChecked in Angular Angular Decorators Observable in Angular using RxJs Create observable from a string, array & object in angular Create Observable from Event using FromEvent in Angular Using Angular observable pipe with example Angular Map Operator: Usage and Examples Filter Operator in Angular Observable Tap operator in Angular observable Using SwitchMap in Angular Using MergeMap in Angular Using concatMap in Angular Using ExhaustMap in Angular Take, TakeUntil, TakeWhile & TakeLast in Angular Observable First, Last & Single Operator in Angular Observable Skip, SkipUntil, SkipWhile & SkipLast Operators in Angular The Scan & Reduce operators in Angular DebounceTime & Debounce in Angular Delay & DelayWhen in Angular Using ThrowError in Angular Observable Using Catcherror Operator in Angular Observable ReTryWhen inReTry, ReTryWhen in Angular Observable Unsubscribing from an Observable in Angular Subjects in Angular ReplaySubject, BehaviorSubject & AsyncSubject in Angular Angular Observable Subject Example Sharing Data Between Components Angular Global CSS styles View Encapsulation in Angular Style binding in Angular Class Binding in Angular Angular Component Styles How to Install & Use Angular FontAwesome How to Add Bootstrap to Angular Angular Location Service: go/back/forward Angular How to use APP_INITIALIZER Angular Runtime Configuration Angular Environment Variables Error Handling in Angular Applications Angular HTTP Error Handling Angular CLI tutorial ng new in Angular CLI How to update Angular to latest version Migrate to Standalone Components in Angular Create Multiple Angular Apps in One Project Set Page Title Using Title Service Angular Example Dynamic Page Title based on Route in Angular Meta service in Angular. Add/Update Meta Tags Example Dynamic Meta Tags in Angular Angular Canonical URL Lazy Load Images in Angular Server Side Rendering Using Angular Universal The requested URL was not found on this server error in Angular Angular Examples & Sample Projects Best Resources to Learn Angular Best Angular Books in 2020

Introduction to Angular| What is Angular?

Angular is the new front-end framework and is the successor to the most popular AngularJs. Angular is open-source and helps us build dynamic & single-page applications (SPAs). In this article, we will give you a brief introduction to Angular.

What is Angular ?

Angular is a development platform and framework for building single-page client applications using HTML and TypeScript. Angular is built usingTypeScript.

Angular has many improvements and innovations over its predecessor, AngularJS. It is easy to learn and develop enterprise-scale applications. You can build extendable, maintainable, testable, and standardized applications using Angular.

Angular provides all the core functionality that you need to develop a client application. It comes bundled with a router module, an HTTP module, a forms API, etc. We can use it to build amazing client-side applications.

Angular is built with testing in mind. When you install Angular, it will also install theJasmine testing framework . Hence, you can get started immediately.

Angular is an opinionated framework. It is a framework that follows a certain design pattern and forces you to follow it. This has its own benefits. Every Angular application will follow the same structure. As a result, if you switch to another project in another company as a developer, the Angular application will look similar.

Introduction to Angular

We have created a great tutorial on How to Install and get started with Angular. And find out how to Create your First Angular Application.

Features of Angular

Angular is loaded with Power-packed Features. Some of the features are listed below

Modular by design

Angular applications follow modular design concepts. The application comprises Angular modules, which are self-contained units of code. We can easily reuse them across the different parts of the application and better organize and manage our codebase.

Component-based structure

Angular components are the backbone of the Angular application. A component represents a piece of the UI. We compose complex UI elements by reusing the existing components.

Templates

Templates represent HTML. Angular enables us to use programming constructs like if conditions, loops, etc., to render and control how the HTML pages look. The component powers the templates.

Two-way data binding

Data binding is the most incredible feature of Angular. It is automatic and fast. Changes in the view or component reflect on the component class and vice versa instantly.

Dependency injection

Angular comes bundled with a dependency injection system, which promotes code reusability. It makes it easier to manage and inject dependencies. We can create Angular services and inject them into component classes.

Routing

Routing is another essential feature of Angular. It makes it easier to navigate between different views without reloading the page. The routing module helps us build single-page applications in Angular.

angular forms

The Angular Forms API provides rich tools for building complex forms. It includes built-in validation and support for reactive forms.

HTTP Module

The HTTP Module allows sending HTTP requests to the back-end server. It is very robust and can cover advanced client-server communication.

Testing

Angular has a built-in testing framework that makes writing and running tests for your application easy.

Active Community

Angular is supported by Google and has a very active community of supporters. It makes a lot of difference, as your queries are quickly resolved.

Key differences between AngularJs & Angular

Support for ES6

Angular is completely written in Typescript and meets the ECMAScript 6 specification. This means that it has support for ES6 Modules, Class frameworks, etc.

Components are new controllers

In AngularJS we had Controllers. AngularJs Controllers are replaced with Angular Components. The controllers and view in AngularJS are defined as follows

                              
 
//View 
<body ng-controller=’appController’>     
    <h1>vm.message<h1> 
</body> 
 
//Controller angular.module(‘app’).controller(‘appController’,appcontroller) {     
    message=’Hello Angular’; 
}
                            
                        

In Angular, we are using Components. The simple component is shown below written using Typescript.

                              

import { Component } from '@angular/core'; 
 
@Component({     
    selector: 'app',     
    template: '<h1>{{message}} </h1>' 
}) 
export class AppComponent  {
      message: string=’Hello Angular’; 
}
                            
                        

In Angular, a component represents a UI element. You can have many such components on a single web page. Each component is independent of the other and manages a section of the page. The components can have child components and parent components.

Directives

AngularJS had a lot of directives. Some of the most used directives are ng-repeat & ng-if

                              

<ul>     
    <li ng-repeat =customer in vm.customers> 
        {{customer.name}}     
    </li> 
</ul> 
<div ng-if=”vm.isVIP”>     <h3> VIP Customer </h3> </div>
                            
                        

Angular also has directives, but with a different syntax. It has a * before the directive name indicating it is a structural directive

                              

<ul>     
    <li *ngFor =#customer of customers>         
        {{customer.name}}     
    </li> 
</ul> 
<div *ngIf=”vm.isVIP”> 
    <h3> VIP Customer </h3> 
</div>
                            
                        

The style directives like ng-style,ng-src & ng-href are all gone. These are now replaced by property binding of HTML elements to the class properties

The creation of Custom Directives is vastly simplified in angular as shown in the example below.

                               
@Directive({     
   selector: '[MyDirective]' 
}) 
class MyDirective { }
                            
                        

Data Bindings

The powerful angular s stay the same, with minor syntax changes.

Interpolation

                              

//AngularJS   
<h3> {{vm.customer.Name}}</h3>  
 
//Angular 
<h3> {{customer.Name}}</h3>
 
                            
                        

Note that we used the controller alias VM to specify the controller instance in AngularJS. In Angular,the context is implied.

One-way binding
                              

//AngularJS 
<h3> ng-bind=vm.customer.name></h3> 
 
//Angular 
<h3 [innerText]=”customer.name” ></h3>
                            
                        
Event Binding
                              

//AngularJS 
<button ng-click=”vm.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=”vm.customer.name”>  
 
//Angular 
<input [(ng-model)]=”customer.name”> 
 
                            
                        

$Scopes Are Out

Angular is not using $scope anymore to glue the view and controller.

AngularJS used to run a dirty check on the scope objects to see if any changes occurred. Then it triggers the watchers. And then it used to re-running the dirty checking again.

Angular uses zone.js to detect changes. Zone.js apply patches on all the global asynchronous operations like click event, timer events, HTTP requests, etc. It then intimates the Angular, whenever the changes occur in the Angular Application. The Angular then runs the change detection for the entire application

Filters are renamed to Pipes

In AngularJS, we used Filters and as shown below

                              

<td>{{vn.customer.name | uppercase}}</td> 
                            
                        

Angular uses the same syntax but names them pipes

                              

<td>{{customer.name | uppercase}}</td>
                            
                        

Platform-specific Bootstrap

In AngularJS we used the ng-app directive in our HTML, then the Angular would bootstrap and attach itself the ng-app

                              
<body ng-app=’app’> </html> 
                            
                        

Bootstrapping in Angular is done through code. The bootstrapping of Angular is not simple as that of AngularJS. The sample code below shows how the Angular application bootstraps the AppModule using platformBrowserDynamic Module

                              
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 
import {AppModule } from './app.module'; platformBrowserDynamic().bootstrapModule(AppModule); 
 
                            
                        

Bootstrap is also Platform-specific in Angular. You can have different bootstrappers for Mobile & Web applications.

You can read about Bootstrapping Angular Application

Services

AngularJS had Services, Factories, Providers, Constants, and values, which were used to create reusable code. These are then injected into Controllers so that it can use it

The Angular all the above is merged into a Service class.

Mobile Support

AngularJS was not built with mobile support in mind. Angular is designed with mobile development in mind.

Summary

This artcle gives a brief Introduction of Angular to you. In the next tutorial, we will learn core concepts of Angular. Subsequently we will show you how to Install Angular and Create your first Angular Application.