Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

Could you explain the various types of filters in Angular 10?

Answer»

Various types of filters can be added by using the pipe character ”|” and then followed by the specific filter. Some of them are-

  • orderBy - This filter orders an array by an expression.
  • uppercase - Set up a string to uppercase
  • lowercase -  Format a string to lowercase
  • number - Present a number to a string
  • date - Present a date to a SPECIFIED format
  • currency - This filter presents a number to a currency format.
  • filter - Helps to SELECT a subset of ITEMS from an array.
  • limitTo - As the name suggests it limits an array or string into a specified number of elements or characters.

Being an Angular Developer is not an easy job. It requires regular practice, staying focused and determined. But I hope these interview questions give you a better understanding of Angular as a framework and a clear picture of what type of questions could be asked in this interview. Just be CONFIDENT and clear in your words.

2.

What is the difference between annotation and decorator?

Answer»

Annotation and decorator both have SYMBOL @ but STILL, they have some different language features-

 AnnotationDecorator
1.These are metadata set on the class using the Reflect Metadata Library.Decorator correlates to a FUNCTION that is called on the class.
2.It is used by the Traceur compiler.It is used by the TYPESCRIPT compiler.
3.Annotations are hardcoded.Decorators are not hardcoded.
4.Annotation Imports: import {ComponentAnnotation as Component} from ‘@angular/core’;Decorator Imports: import {Component} from ‘@angular/core’;
3.

How do observables differ from promises in angular?

Answer»

Both observables and promises DEAL with asynchronous functionalities in Javascript however differ by one another-

 ObservablesPromises
1.Observables are lazy i.e. they won't be executed until we subscribe them by subscribe() method.Are not lazy i.e. they executed just after creation.
2.They deal with multiple asynchronous EVENTS at a time.Promises handle SINGLE asynchronous events at a time.
3.You can cancel the SUBSCRIPTION using the unsubscribe() method.They are not cancellable.
4.Observables deliver bugs to the subscribers.It passes the ERRORS to child promises.
4.

What is the AOT Compilation?

Answer»

As we know all the angular applications require a COMPILATION process before displaying them on the browser.

AOT i.e. Ahead of time is ALSO a compiler that converts Typescript CODE and Angular HTML into javascript code during the build phase of an application and that’s what it makes superior to all compilers as it COMPILES the code at the time of build process not during the RUNNING phase of an application.

5.

How does Angular 10 integrate with bootstrap?

Answer»

Some of how we can integrate these two are-

  • Installing bootstrap via npm and importing @import “~bootstrap/dist/css/bootstrap.css”; in src/styles.css i.e. importing bootstrap files in style.css file.
  • By installing jquery and bootstrap via npm and adding scripts and styles to angular.json.
  • In src/index.html users can import bootstrap style and script files.
  • By adding Bootstrap CSS and JAVASCRIPT files in the <HEAD> SECTION of the index.html file of your angular APPLICATION.
6.

What are the lifecycle hooks in angular 10?

Answer»

LIFECYCLE hooks in angular are callback functions that angular calls when some events take place during the component's LIFE cycle. Let’s understand this concept with some examples-

  • ngOnDestroy- This lifecycle hook is called by the angular when a component is destroyed.
  • ngOnChanges- When a component’s INPUT property changes, angular invokes ngOnChanges.
  • ngOnInit- This lifecycle hook is called when a component is initialized for the FIRST time by angular.
7.

What are the benefits of using HTTPClient in Angular 10?

Answer»

In Angular10 HTTP Client PROVIDES EASY to USE APIs and many other FEATURES like-

  • Testing APIs i.e. Application Programming Interfaces
  • Request and Response interceptors.
  • Typed Requests and Response objects
  • Observable BASED APIs
  • Handling errors in a better way.

Note: Before using all these features users have to import HttpClient in your angular application.

8.

What do you mean by the Wildcard Route?

Answer»

To handle the INVALID URLs in angular APPLICATIONS Wildcard Routes are used.  If a developer is BUILDING an application and let’s suppose he/she has entered some invalid URL or deleted some existing URL then we all have OBSERVED this default error “404 pages not found”.

  In such cases instead of displaying this error, the user can show a custom error page and that is possible only because of the Wildcard route.

9.

Which one is the best out of AOT and JIT?

Answer»

AOT and JIT both are used for compilation but AOT is superior to JIT because of the following differences-

 JITAOT
1.JIT compiles the code just before displaying an application i.e. at RUNTIME.AOT has already compiled the code at the time of BUILDING an application, so it doesn’t have to compile at runtime.
2.Due to compilation at runtime LOADING in JIT is slow.Loading in AOT is fast as code has been already compiled.
3.One can see binding ERRORS at only display time.Template binding Errors can be caught when building your application.
4.The BUNDLE size is higher.Bundle size is half of the bundle size of JIT.
10.

What are the new features of Angular 10?

Answer»
  • New Date Range Picker- By mat-date-range-input and mat-date-range-picker COMPONENTS you can use this new feature of Angular10.
  • New Default Browser Configuration- In Angular 10 many by default browsers are excluded because of disabling ES5 build in new projects.
  • Keeping up to date with Ecosystem- Some updates like Typescript, TSlib, and TSlint are introduced to keep it updated with the JAVASCRIPT ecosystem.
  • Warning about commonJS imports- In angular 10 when you will use any dependency that is related to commonJS a warning message will come.
  • Removals- Some of the removals also happen in Angular 10 like it no LONGER INCLUDES ESM5 and FESM5 bundles, old browsers like IE 9 and 10, Typescript 3.6 and 3.7.
  • Bug Fixes and Resolved Issues- Many bugs related to Router, Core, Modules, COMPILERS, Service Workers got fixed in this version.
11.

What is meant by HostListener and HostBinding in Angular 9?

Answer»

In ANGULAR 9, HostListener is a function decorator. Its job is to accept an event name as an argument and call the associated function when the same event gets fired by the host element.

Whereas, HostBinding in Angular 9 is used for binding the input properties in the host element towards the directive. With the help of HostBinding decorator, a directive can internally LINK property to the input property of the host element. When the INTERNAL property is changed or UPDATED, the input property of the host element will automatically change.

12.

What are the performance improvements in Angular 9?

Answer»

Below is a list of the performance updates made in Angular 9:

  • We are binding the updated benchmark while also converting all the node-based parameter to be used as a testing harness.
  • I was AVOIDING metamorphic reads during the process of property binding.
  • Minimizing repeated lview reads inside the pipe instructions.
  • Eradicating any unnecessary DOM reads in the styling instructions.
  • Initializing TNode inputs/outputs on the very first creation PASS for Ivy.
  • The limit TNode.outputs reads for Ivy.
  • The language-service keeps the analyzedModules CACHED when source files are not changed.
9. Angular runs on which port?

By default, Angular runs on port 4200. But this can be changed later on as PER your usage.

13.

What are the services in Angular 9?

Answer»

Services in ANGULAR are singleton objects. This singleton objects only instantiate once during application lifetime. Moreover, Angular service RETAINS the data throughout the application's life by using specific methods comprised of it.

Thus, Angular services share business, components, functions, and data with other parts of LANGUAGE and organizing an application. A controller directive can invoke the FEATURES of Angular service.

14.

Explain the improvements of Tree-Shaking in Angular 9?

Answer»

The Tree Shaking function can be PERFORMED in both Renderer2 and the Ivy. In some cases where we have an imported function hidden by a false conditional, that function will also be included in the bundle, ALTHOUGH it's never called for renderer 2.

On the other hand, Ivy breaks things down into smaller and more atomic functions. These functions make the renderer code a LOT more FRIENDLY towards tree-shaking because they generate the code, which is necessary from the template you've written. As a result, you no longer ship the entire framework code; instead, only bundle pieces of the framework functionality that you USE.

15.

How to generate a class in Angular?

Answer»

USE the FOLLOWING command to GENERATE a CLASS in Angular through CLI.
ng generate class myClass [OPTIONS]

16.

How to share the data between components in Angular 9?

Answer»

Many times you will have the requirement of sharing the data between components. It can be a parent to child, child to parent, and separate parts. So let's understand this with the help of an example.

Parent To Child Component - any data from parent to child component can be shared with the help of @Input decorator.

Example

IMPORT { Component } from '@angular/core';
@Component({
  selector: 'app-parent',
  template: ``,
  styleUrls: ['./parent.component.css']
})
EXPORT class ParentComponent{
  parentMessage = "message from parent"
  constructor() { }
}

import { Component, Input } from '@angular/core';
@Component({
  selector: 'app-child',
  template: `Say {{ childMessage }}`,
  styleUrls: ['./child.component.css']
})
export class ChildComponent {
  @Input() childMessage: string;
  constructor() { }
}
Child To Parent Component 1 - you can share the data from child

component to parent using @Output decorator.
import { Component } from '@angular/core';
@Component({
  selector: 'app-parent',
  template: `Message: {{message}}`,
  styleUrls: ['./parent.component.css']
})
export class ParentComponent {
  constructor() { }
  message:string;
  receiveMessage($event) {
    this.message = $event
  }
}

import { Component, Output, EventEmitter } from '@angular/core';
@Component({
  selector: 'app-child',
  template: `Send Message `,
  styleUrls: ['./child.component.css']
})
export class ChildComponent {
  message: string = "HELLO Testing!"
  @Output() messageEvent = new EventEmitter();
  constructor() { }
  SENDMESSAGE() {this.messageEvent.emit(this.message) }
}

17.

How Angular is different from AngularJS?

Answer»
AngularAngularJS
It's a modern web application framework built on TYPESCRIPT language.This is a frontend MVC framework built on JAVASCRIPT language.
It is based on services/controller architecture.It follows the MVC architecture.
In this, applications depend on controllers for managing data flow.It is based on SCOPES and controllers, which are less reusable.
It is more flexible and STABLE than AngularJS.It is CHALLENGING to manage and less flexible than Angular.
It is best suited for SPAs and complex round-trip applications.It is best suited for maintaining and testing client-side applications.
18.

What are some of the new features in Angular 9?

Answer»

Here is a list of some of the new FEATURES in Angular 9

  • JavaScript Bundles and Performance - A production BUILD with Angular 8.2.7 resulted in a main.js of 246KB for ES2015 browsers. In Angular 9, this was reduced to 214KB, a 13 percent improvement from Angular 8.
  • Ivy Compiler - Ivy yields much smaller JavaScript bundles, so Ivy solves Angular's bundle weaknesses.
  • Selector-less Bindings - The Angular ViewEngine supports this PATTERN in the previous versions, but it was missing in Ivy's initial release.
  • Internationalization - You can use the Angular CLI to generate the standard code necessary to create files for the translators. After configuring your app to use i18n, you can smoothly run the xi18n command for extracting the localizable text into a file.
19.

What is the provider in Angular?

Answer»

In Angular dependency, INJECTION is used to INJECT the dependencies of services. A Provider works as an instructor for the dependency injection system to RESOLVE the dependencies. When you CREATE any SERVICE, it comes with default @Injectable decorator that contains a default property 'providedIn,' which establishes the provider for service.

Example

@Injectable({
  providedIn: 'root',
})
export class DataService {
}

You can inject the services in the root or particular module as well, and you can limit the scope of service to a particular component by using component providers.

@Component({
  providers: [DataService]
})

 

20.

What are the differences between Constructors and OnInit?

Answer»
ConstructorsOnInit
It is the default METHOD USED for constructing components.It is an Angular 5 life cycle event method.
It is a TypeScript feature which is used for class instantiationsIt is used when there are any changes in the input or OUTPUT binding values.
It is CALLED before the ngOnInit()It is called after the constructors and the first ngOnChanges.
21.

What is the proper lifecycle hooks for the application development in Angular 5?

Answer»

In Angular 5, all the components or directives have specific lifecycle events that are being managed by the @angular/core. They are used in the creation of components, rendering it, creating and rendering their children components in the hierarchy.
These components or directives process changes as and when the multiple data-bound properties have any change, and then destroy them before the removal of their templates from the DOM. Angular 5 provides a specific set of lifecycle hooks, also known as SPECIAL events that are used to tap into this lifecycle while performing operations when there is a necessity.
In addition, the constructor is used to EXECUTE all the PRIOR lifecycle events. Each and every interface comes with a single hook method prefixed with the ng. For example, the ngOnint interface has the ONINIT method which needs to be implemented into the COMPONENT.

22.

How Do We Import A Module In Angular 5?

Answer»

To IMPORT a module successfully in ANGULAR 5, we use this SYNTAX:
import { ModuleName } from 'ModuleLocation';

23.

List the types of Data Binding supported by Angular 5?

Answer»

DATA BINDING is the process of synchronizing the model and view to enable effective COMMUNICATIONS between the COMPONENTS and DOM.
In Angular 5, there are four types of Data Binding

  • Property Binding
  • Event Binding
  • Two-Way Data Binding
  • Interpolation
24.

What are Event Emitters and how do they work in Angular 5?

Answer»

Now, Unlike Angular 1, Angular 5 does not have a bi-directional DIGEST cycle. In this version, any changes OCCURRING within the component generally get propagated to all the children components present in the hierarchy through the current component.
If there is any change in one component which needs to be REFLECTED in its parent component in the respective hierarchy, you can easily emit an event using the Event Emitter API which is native from Angular 5.
So basically, EventEmitter is defined via a class in the @angular/core module which is used EQUALLY by components and directives for emitting any custom events.

25.

Name the list of the building blocks of Angular?

Answer»

Here is a LIST of the BUILDING BLOCKS of the ANGULAR Framework

  • Modules
  • Components
  • Templates
  • Data Binding
  • Metadata
  • Dependency Injection
  • Services
  • Directives
26.

What are the new features rolled out in Angular 5?

Answer»

The ANGULAR 5 version consists of a bunch of new features and performance-enhancing improvements in addition to multiple bug fixes to make the coding WORK for Angular & Javascript Developers a lot easier than its predecessor, Angular 4. Here is a list of all the features in this version:

  • Switching to the AOT compiler by default.
  • An INTEGRATED watch mode
  • Included type for checking in multiple templates
  • Versatile and increased flexibility of metadata
  • Removal of the *.ngfactory.ts files
  • Improved error messages for EASY fixing
  • Allowing multiple exports aliases
  • New “Tree Shakeable” components section
  • Option for Hybrid Upgrade of Application
  • Updates in the I18n (Internationalization) Pipes.
27.

How to rollback the whole object when navigating back to a page managed by Angular Router in Angular 8?

Answer»

The ANGULAR router in Angular 8 ENABLES rollback the whole object to the next as USERS perform application work. To present a specific component view a given URL, Angular Router is the foremost service that presents. In order to import an Angular router, it is mandatory to install a library package, @angular/router.

Related Article: What is LAZY loading in AngularJS
28.

What is typeofchecks in Angular 8?

Answer»

The WORKING of typesofchecks in Angular 8 is similar with the enabled and disabled flag, which MEANS if you want to test whether the selected VALUE is an object or not, then the following syntax is used " Typeof value = = = 'object' ". In angular 8 the folwing TYPES of checks are used such as “Typeof value.ngOnDestroy = = = 'function' “.

29.

What is the difference between real Dom and virtual Dom?

Answer»
Real DOMVIRTUAL DOM
DOM is a language-neutral interface allowing programs and scripts to dynamically access and UPDATE multiple objects like content, structure, and style of a DOCUMENT.Is a collection of modules designed to provide a declarative way to represent the DOM for an application.
The DOM represents the document as nodes and objects.A virtual DOM object is a representation of a DOM object, like a lightweight copy.
It is an object-oriented representation of a web page, modified with a scripting language like JavaScript.Virtual DOM is IDEAL for mobile-first applications.
30.

Why Incremental DOM is Tree Shakable?

Answer»

In Angular 8, the framework does not interpret components in an INCREMENTAL DOM. It uses component references instructions, and if it does not refer to a PARTICULAR instruction, it shall be left unused. Now, VIRTUAL DOM requires an EXTERNAL interpreter. Hence, not KNOWING which components to display, everything is shifted to the browser, making the DOM shakeable.

31.

What is runGuardsAndResolvers in Angular 8?

Answer»

Angular 8 introduced a number of new and UNIQUE options to runGuardsAndResolvers. In GENERAL, runGuardsAndResolvers is an option which is used for the Angular router configuration in order to control the resolvers and guards. The FIRST option available in runGuardsAndResolvers is pathParamsChange. Through, this option router will re-run the guards and resolvers. Whenever you want to control over the resolvers and guards, USE runGuardsAndResolvers option in Angular 8.

32.

How to install Angular 8?

Answer»

Steps for the Installation of ANGULAR 8 ENVIRONMENTAL setupStep 1

Before installing Angular IDE using Angular CLI tool, make sure that Node.js has already INSTALLED in your SYSTEM.

  • 1. If Node.js is not installed in your system install it using the following steps.
    • The basic requirement of Angular 8 is Node.js version 110.9.0 or later.
    • Download it using https//nodejs.org/en/
    • Install it on your system
    • Open node.js command prompt
    • CHECK the version run command, node-v in the console window
Step 2

In order to install Angular CLI, use the following commands 2) npm install –g @angular/cli or npm install –g @angular/[email protected]

Step 3

To check the node and angular CLI version, run command ng –version on the console terminal

33.

What is authentication and authorization in Angular?

Answer»
AuthenticationAuthorization
Process of verifying the userProcess of verifying that you have relevant access to any procedure
Methods: LOGIN form, HTTP Authentication, HTTP digest, X 509 Certificates, and CUSTOM Authentication method.Methods: Access CONTROLS for URL, SECURE objects and methods and Access Control Lists (ACL)
34.

What is HostListener and HostBinding?

Answer»
35.

Which command is used to run static code analysis of angular application?

Answer»

The ng lint COMMAND is used to run static CODE analysis WITHIN an ANGULAR APPLICATION.

36.

What is NgUpgrade?

Answer»

NGUPGRADE in Angular 8 is a library which is used to integrate both Angular and ANGULARJS COMPONENTS in an application and also help in bridging the dependency injection systems in both Angular & AngularJS.

Related Interview QUESTIONS: Angular 4 Interview Questions
37.

What is the use of RxJS in angular8?

Answer»

Angular 8 uses OBSERVABLES which are implemented using RxJS libraries to push CODE. The main job of RxJS is to WORK with asynchronous events.

38.

What are new features in Angular 9?

Answer»

Here are the top new features of Angular 9

  • An undecorated CLASS MIGRATION schematic ADDED to the core.
  • Numeric Values are ACCEPTED in the formControlName.
  • Selector-less directives have now been allowed as base classes in View Engine in the compiler.
  • Conversion of ngtsc DIAGNOSTICS to ts.Diagnostics is possible
39.

Why typescript is used in angular 8?

Answer»

Angular uses TypeScript because:

  • It has a wide RANGE of tools
  • It’s a superset of Angular
  • It makes abstractions explicit
  • It makes the code EASIER to read and understand.
  • It takes most of the usefulness within a language and BRINGS it into a JS environment without FORCING you out.
40.

How can you hide an HTML element just by a button click in Angular?

Answer»

Ng-HIDE command is used to hide HTML elements if an expression is TRUE.

Here's an example:

<div ng-app="DemoApp" ng-controller="DemoController">
   <input type="button" value="Hide Angular" ng-click="ShowHide()"/>
   <div ng-hide="IsVisible">Angular 8</div>
</div>
<script type="text/javascript">
   VAR app = angular.module('DemoApp',[]);
   app.controller('DemoController',function($scope){
   $scope.IsVisible = FALSE;
   $scope.ShowHide = function(){
     $scope.IsVisible = $scope.IsVisible = true;
   }
});
</script>

 

Now in the above, when the Hide Angular button is not clicked(the expression is set to false)

41.

How to upgrade angular 7 to 8?

Answer»

Steps to upgrade Angular 7 to 8

  • Install TYPESCRIPT 3.4
  • Use NODE LTS 10.16 or its ADVANCED version
  • Run command on terminal panel/CLI -> ng UPDATE @angular/[email protected]/core

Alternative- use URL link- HTTPS://update.angular.io/

Related Article: Angular 6 Interview Questions
42.

Why we used Service Workers in Angular?

Answer»

A Service WORKER is used in Angular 8 to build the BASIC steps of converting an application into a Progressive Web App (PWA). Service workers function as NETWORK proxies and intercepting all outgoing HTTP requests MADE by the application and how to respond.

Related Article: ANGULARJS vs. Angular 2 vs. Angular 4: What's the Difference
43.

How Performance Improvements on the core in Angular 8?

Answer»

Angular 8 has advanced level features which ensure systematic workflow and PERFORMANCE IMPROVEMENTS. It has apparent features such as differential loading, CLI workflow improvements, Dynamic imports for LAZY ROUTES, Ivy rendering engine, Bazel, etc.

44.

What are the limitations of Web Workers?

Answer»

Here are the limitations of a WEB Worker:

  • A web worker cannot DIRECTLY manipulate the DOM
  • It has limited access to methods and properties of the WINDOW object.
  • It cannot be run directly from the file system. A web worker NEEDS a server to run.
45.

What are the new features in angular 8?

Answer»

Angular 8 it has following new FEATURES such as

  • Differential loading- It is a technique that automatically makes your angular applications more performant. When you BUILD applications for production, two bundles are created- One bundle for Modern BROWSERS that support ES6+ and another bundle for older browsers that only support ESS.
  • Dynamic imports for lazy routes- In Angular version 8 there is nothing new in the concept of lazy routes itself but the syntax has totally changed. In the older version of Angular CustomString Syntax is used, but angular 8 uses standard dynamic import syntax so the syntax which is customized to Angular is migrated to industrial standard.
  • Ivy rendering Engine- It translates the templates and components into regular HTML and javascript that the browser can interpret and understand.
  • Bazel- It is a building tool through which angular developer can build backends and frontends.
Also Read: Angular 2 Interview QUESTIONS
46.

What is the purpose of Codelyzer?

Answer»

Codelyzer is an open-source TOOL in Angular 8 whose MAIN FUNCTION is to check for ERRORS in codes not following pre-defined guidelines. It runs on the tslint.json file and checks only the static code in Angular 8.

47.

What is the difference between promise and observable in angular8?

Answer»
ObservablesPromises
Both SYNCHRONOUS as well as asynchronousAlways asynchronous
Can emit MULTIPLE valuesProvides only ONE single value
It is lazyIt is EAGER
48.

What is the purpose of Wildcard route?

Answer»

WILDCARD routing is used in ANGULAR 8 for DEFINING the route of pages. Specific changes/updates can be MADE when defining the route using Wildcard.

49.

What is bazel in Angular 8?

Answer»

In Angular 8, Bazel is a new build SYSTEM and it is available for a short period of time. It is the new FEATURE of Angular 8, which provides a PLATFORM to make your backends and frontends with a similar tool. It has the possibility to have remote builds as well as cache on the build farm.

The main FEATURES of Bazel are-
  • It is an internal build tool, through which application can be customized.
  • It ALSO tests the action and performance of multiple machines.
  • It constructs a graph through which you can identify the useful information.
  • It also supports customization.
Related Interview Questions: Angular 9 Interview Questions
50.

What is the difference between Angular 7 and Angular 8?

Answer»
Angular 7Angular 8
Angular 7 is difficult to useAngular 8 is easier to use
It has features such as Virtual scrolling, CLI prompts, Application performance, Drag, and drop, Bundle BUDGET, Angular compiler, Angular elements, NativeScript, Better error handling, etc.It has unique and advanced level features such as Differential Loading, Ivy rendering ENGINE, API builders, Bazel support, Support for $LOCATION, Router backward compatibility, Opt-In Usage sharing, web- workers, etc.
Breaking changing in Angular 7 are- COMPONENT Dev Kit (CKD), Material design library and virtual scrolling.Breaking changing in Angular 8 are- Core framework, Angular, material library and CLI.
It will support a lower version of typescript version 3.4.It will not support a lower version of typescript version 3.4.
It supports all TYPES Node.js versionIt supports Node.js version 12 or later