AngularJs is very powerful JavaScript framework. It was released in October 2010. AngularJS based on Model View Controller (MVC) architecture and automatically handles JavaScript code suitable for each browser.
Angular 2.0 was released in September 2016. It is re-engineered and rewritten version of AngularJS. AngularJs had a focus on controllers but, version 2 has changed focus on components. Components are the main building block of application. It supports capricorn horoscope personality features for speed in rendering, updating pages and building cross-platform native mobile apps for Google Android and iOS.
Angular 4.0 was released in March 2017. It is updated to TypeScript 2.2, supports ng if-else conditions whereas Angular 2 supported only if conditions. Angular 4.0 introduces animation packages, Http search parameters and finally angular 4 applications are smaller and faster.
Angular 5.0 was released in November 2017. It supported some of the salient features such as HTTPClient API, Lambda support, Improved Compiler and build optimizer.
Angular 6.0 was released in May 2018. Features added to this version are updated Angular CLI, updated CDK, updated Angular Material, multiple validators and usage of reactive JS library.
Angular 7.0 was released in October 2018. Some of salient features are Google supported community, POJO based development, modular structure, declarative user interface and modular structure.
The following building blocks play a crucial role in Angular:
Components: A component can control numerous views wherein each of the views is a particular part on the screen. All Angular applications have a minimum of one component called the root component. This component is bootstrapped in the root module, the main module. All the components include the logic of the application that is defined in a class, while the main role of the class is to interact with the view using an API of functions and properties.
@Component({
selector: “app-greet”,
template: `<div>
<h1> Hello {{name}} how are you ? </h1>
<h2> Welcome to interviewbit ! </h2>
</div>`
})
Data binding: Data binding is the process in which the various sections of a template interact with the component. The binding markup needs to be added to the HTML template so that Angular can understand how it can connect with the component and template.
app.component.ts
import { Component } from “@angular/core”;
@Component({
selector: “app”,
templateUrl: “./app.component.html”,
})
export class AppComponent {
data = “This is an example component of two way data binding.”;
}
app.component.html
<input [(ngModel)]=”data” type=”text”>
<br> <br>
<h2> You entered the data: {{data}}</h2>
app.module.ts
import { NgModule } from “@angular/core”;
import { BrowserModule } from “@angular/platform-browser”;
import { FormsModule } from “@angular/forms”;
import { AppComponent } from “./app.component”;
@NgModule({
imports: [BrowserModule, FormsModule],
declarations: [AppComponent],
bootstrap: [AppComponent],
})
export class AppModule {}
Dependency injection: It uses DI so that it can offer the necessary dependencies, mainly services, to the new components. The constructor parameters of a component inform create simple captcha javascript Angular regarding the numerous services needed by the component, and DI provides a solution that gives the necessary dependencies to the new class instances.
Directives: Angular templates are of dynamic nature, and directives help Angular understand how it can transform the DOM while manifesting the template.
Metadata: Classes have metadata attached to them with the help of decorators so that Angular will have an idea of processing the class.
Modules: Module or NgModule is a block of code organized using the necessary capabilities set, having one specific workflow. All Angular applications have at least one module, the root module, and most of the applications have numerous modules.
import { BrowserModule } from ‘@angular/platform-browser’;
import { NgModule } from ‘@angular/core’;
import { AppComponent } from ‘./app.component’;
import { TestComponent } from ‘./test/text.component’;
@NgModule({
declarations: [
AppComponent,
TestComponent
],
imports: [
BrowserModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Routing: Angular router helps interpret the URL of a browser to get a client-generated experience and view. This router is bound to page links so that Angular can go to the application view as soon as the user clicks on it.
Services: Service is a vast category that ranges from functions and values to features that play a significant role in Angular applications.
import { Injectable } from ‘@angular/core’;
@Injectable({
providedIn: ‘root’
})
export class TestServiceService {
constructor() { }
}
Template: The view of each component is linked with a template, and an Angular template is a type of HTML tag that allows Angular to get an idea of how it needs to render the component.