Best Online Tutorials

SQL Tutorial

Free SQL Tutorial

SQL Interview Questions

SQL Practice Questions

SQL Tips & Tricks

SQL Errors

SQL Books

Angular Tutorial

Free Angular Tutorial

Angular Interview Questions

Angular Practice Questions

Angular Tips & Tricks

Angular Errors

Angular Books

Node.js Tutorial

Free Node.js Tutorial

Node.js Interview Questions

Node.js Practice Questions

Node.js Tips & Tricks

Node.js Errors

Node.js Books

React.js Tutorial

Free React.js Tutorial

React.js Interview Questions

React.js Practice Questions

React.js Tips & Tricks

React.js Errors

React.js Books

SSIS Tutorial

Free SSIS Tutorial

SSIS Interview Questions

SSIS Practice Questions

SSIS Tips & Tricks

SSIS Errors

SSIS Books

SEO Tutorial

Free SEO Tutorial

SEO Interview Questions

SEO Practice Questions

SEO Tips & Tricks

SEO Errors

SEO Books

Javascript Tutorial

Free Javascript Tutorial

Javascript Interview Questions

Javascript Practice Questions

Javascript Tips & Tricks

Javascript Errors

Javascript Books

MongoDB Tutorial

Free MongoDB Tutorial

MongoDB Interview Questions

MongoDB Practice Questions

MongoDB Tips & Tricks

MongoDB Errors

MongoDB Books

Next.js Tutorial

Free Next.js Tutorial

Next.js Interview Questions

Next.js Practice Questions

Next.js Tips & Tricks

Next.js Errors

Next.js Books

Angular interview questions | Part 3 

Prashant Surya  |   Oct 21, 2019  |  Views: 520
pictures

Description:

31.  What is the difference between an Annotation and a Decorator in Angular?

Decorators are actually the functions, which extends the class object behavior at design time,  by annoting them.

But the decorators are imported as a annotation from '@angular/core' and attached with the class using the sign @.

Example:

@Pipe
class TestPipe { }

Here @Pipe is an annotation that tells the Angular, that the class with which the annotation is attached to will get the Pipe behavior.


32.  What is Transpiling in Angular?

Transpiling means compilation of one High Level Language into another High Level Language.

So In Angular, we use TypeScript ( A subset of JavaScript) which is a High Level Language, so as to maintain OOPS concept.

But our browser understands only the JavaScript, which again a High Level Language.

So we have to transpile the TypeScript to JavaScript (one High Level Language into another High Level Language), that's what the transpiling in Angular.


33.  How to communicate between the parent and child component in angular?


Using @Input / @Output:

@Input is defined in child component to receive the value from parent component.

@Output is defined in child component to emit the data or event from child component, which parent component receives.


Using @ViewChild / @ContentChild:

@ViewChild is used to get the instance of the child component and then can access any properties of that child component.

@ContentChild is used to get the instance of the content within the child component and then can access any properties of that component.



34.  What is the use of base href in angular?

Base href is used in angular to set the base portion or the static portion of URL.

After that part of URL, the angular router considers for the routing path.

When we define Router Module in any angular application, we have to tell it that the whats your static part of URL, so that it can start considering for their router path.

<base href="/">

Its to be placed in the index.html head tag (main HTML file for angular application)



35.  How to define Singleton services in angular ?

Singleton services are the services which are only initialized once in a application.

Only one instance is created in the whole application.

Means only one time memory is given, and it retains the same memory for the entire application.

It is used to share data from one components to another.

It can be defined by two ways:

Declare service as root :

Decorator @Injectable() has providedIn property, which is set to 'root'.

import { Injectable } from '@angular/core';
@Injectable({
  providedIn: 'root',
})
export class DemoService {
}

Include service in MainModule:

Include the service in the MainModule or in a module that is only imported by the MainModule.



36.  What is a declarable in angular?

Declarables are the classes that are need to be declared inside the declarations array in the NgModule.

There are three only classes that are declarable in angular:

components
directives
pipes 



37.  What is the difference between BrowserModule or CommonModule ?


BrowserModule:

It should be imported only once in a application in the MainModule's imports array.

It provides the essential services required to launch and run a browser application.

Do not import BrowserModule in any others module.

import {BrowserModule} from @angular/platform-browser;

CommonModule:

It can be imported in any Feature modules and lazy-loaded modules.

Its is used to get access of Angular providers like *ngIf,*ngFor.

import {CommonModule} from @angular/common



38.  What is the use of forRoot() method in angular?

forRoot() is a static method given in Module class, to set its singleton behavior in the root of Application.

forRoot() and forChild() are static methods that configure services in the root and feature modules respectively.



39.  What if the two modules provide the same service?

If the two modules have same services provided, and it gets loaded at the same time, the last loaded modules's provided service gets the instance of the service and both the modules uses the same service instance.



40.  What are the types of modules available in angular?

In Angular we have two types of modules:

Shared Module:
Shared modules have to re-export the components, directives, and pipes.
Shared Module doesn't re-export providers.
It is created to share the common business logic, reusable components, pipes within multiple Modules in the application.

Featured Module:

Featured module are the normal modules, which can't be shared.
It contains a particular feature, such as routes, services, widgets, etc.



41.  What is HttpClient in angular?

HttpClient is the angular inbuilt service used to handle HTTP request in angular.

HttpClient is avaliavle by importing HttpClientModule.

import { HttpClientModule } from '@angular/common/http';

HttpClient offers a simplified client HTTP API for Angular applications that rests on the XMLHttpRequest interface exposed by the browsers.



42.  What is difference between HTTP and HttpClient in angular?

Http are introduced at the staring of angular to handle HTTP request response.

HttpClient was later introduced in angular 4.3

HttpClient is an improved replacement for Http.

import { HttpClientModule } from '@angular/common/http';
import { HttpModule } from '@angular/http';



43.  What are the Entry Components in angular?

Entry Components are the components declared, to tell angular to use it as its default component which to be render on the index.html at first load.
Entry Components are of two kinds:

At bootstrap in main module:

We declare a entry component in the bootstrap array in NgModule of appplication level module (root module).

At route:

We declare a component in a route definition.



44.  What are the available metadata of NgModule in angular?


Eight metadata are available in NgModule:

providers
declarations
imports
exports
entryComponents
bootstrap
schemas
id


@NgModule({
  providers?: Provider[]
  declarations?: Array<Type<any> | any[]>
  imports?: Array<Type<any> | ModuleWithProviders | any[]>
  exports?: Array<Type<any> | any[]>
  entryComponents?: Array<Type<any> | any[]>
  bootstrap?: Array<Type<any> | any[]>
  schemas?: Array<SchemaMetadata | any[]>
  id?: string
})



45.  What is AsyncPipe in angular?

AsyncPipe is a special kind of impure pipe which makes rendering data from observable and promises much easier. 
For promises it automatically adds a then callback and renders the response.

The async pipe subscribes to the given Observable or Promise and returns the latest value it has emitted in response. 

When the value is emitted it marks the component to be checked for the further changes. 

When the component is destroyed it gets unsubscribes automatically to avoid the potential memory leakage.









Comments:
Content Contributor
Prashant Surya

Prashant Surya

Software developer at Uniserve Data Technologies Pvt. Ltd.  |   Noida, Uttar Pradesh, India

I am a software developer, freelancer and trainer working on technologies likes. MEAN stack, MERN Stack, ASP.NET full stack, WebRTC, socket.io ,PWA, SQL, JavaScript, jQuery, HTML, CSS, SEO, responsive UI/UX designing... having 7 years of experience in development in multiple domains like, eCommerce, RTA, capital markets, education, real estate...


Read related articles

Angular interview questions | Part 4

Prashant Surya  |   Oct 25, 2019  |  Views: 580

Angular interview questions | Part 3

Prashant Surya  |   Oct 21, 2019  |  Views: 521

Angular interview questions | Part 2

Prashant Surya  |   Oct 15, 2019  |  Views: 722

Angular interview questions | Part 1

Prashant Surya  |   Oct 13, 2019  |  Views: 958

Want to sell your software ?-

If you want to sell your readymade software to the genuine clients or businessman, list your software with details and demo links.

  • Sell ERP
  • Sell Website Clones
  • Sell App Clones
  • Sell Readymade Portals
  • Sell Readymade Websites
  • Sell Mobile Apps
  • Sell Window Apps

Clients will find it using our advanced search filter and will contact you directly.

No any charge for the product lsiting.

Do you own a Company ?+

Property.sale

Buy or Sell Commercial Property+

Are you a freelancer ?+

Looking for a job ?+

Are you a Service Provider ?+

Are you a blogger ?+

Do you own an IT Institute ?+



Property.sale