Angular 2 Interview Questions

1) What is Angular 2?

It is an open source JavaScript framework which is used to build web applications in JavaScript and HTML.

It is also used to overcome obstacles encountered while working with Single Page applications.

2) What are the features of Angular 2?

Features of Angular 2 are:

  • Components: Helps in maintaining the application and to build the applications into many modules
  • TypeScript: TypeScript is a superset of JavaScript
  • Services: Set of code that can be shared by different components of an application

3) What are the components available in Angular 2?

The components available in Angular 2 are:

  • Modules
  • Component
  • Templates
  • Metadata
  • Service

4) What are the ways to get started with your first Angular JS application?

There are three ways to get started with your first application are:

  • Use scratch
  • Use the quick start at Angular Github
  • use Angular CLI

5)What is NgModule decorator?

NgModule decorator is used to define the declarations, imports and bootstrapping options.

6) What is Import and Export array?

Import array is used to import the functionality from other Angular JS modules.

Export array is used to export directives, components and pipes.

7) What are the advantages of using Angular 2 over Angular 1?

Advantages of using Angular 2 over Angular 1:

  • Modular
  • Easy to Learn
  • Cross platform
  • Angular 2 is also a platform
  • Better Speed and Performance
  • ES6 and Typescript is also available

8) What are the lifecycle phases of Angular 2 application?

Lifecycle phases of Angular 2 application:

  • constructor
  • ngOnChanges
  • ngOnInit
  • ngDoCheck
  • ngAfterContentInit
  • ngAfterContentChecked
  • ngAfterViewInit
  • ngAfterViewChecked
  • ngOnDestroy

9) What is Routing in Angular 2?

Routing helps in enables user to navigate between views and components.

Angular 2 simplifies routing and provide flexibility.

10) What is Date filter?

Date filter: It is used to convert the input string to date format.

11) What is Dependency Injection?

Dependency Injection: It is the ability to add the functionality of components at runtime.

12) What is CLI?

CLI stands for Command Line Interface, and it is used to create Angular JS application.

13) What are Angular 2 directives?

Commonly used filters are:

It is a custom HTML element which is used to extend the power of HTML.

Types of Angular 2 directives:

  • ngif
  • ngFor

14) Which components are used to configure routing in Angular 2?

Three main components are:

  • Routes
  • RouterOutlet
  • RouterLink

15) What are Modules in Angular 2?

Modules are used to put logical boundaries in your application. To separate the functionality of your application, you need to build everything into separate modules.

16) Which command is used to check the version of node.js in the command prompt?

The command used is: node -v.

17) Which command is used to install npm (node package manager)?

The command used is: npm install (inside Node.js command prompt).

18) What is TypeScript?

TypeScript: It is a superset of JavaScript which is used for application-scale development. TypeScript is also an object-oriented and compiled language.

19) What is Shadow Dom in Angular2?

Shadow Dom: It refers to a subtree of DOM elements which is the part of the document, but not into the main document of DOM tree.

Here, the Shadow Dom is created when we are creating a component in Angular2.

20) What is Codelyzer in Angular2?

Codelyzer: It is an open source tool which is used to check whether the pre-defined coding guidelines has been followed or not.

21) What are Event Emitters in Angular2?

Event Emitters: It is a class defined in @angular/core module which is used by components and directives to emit custom events.

22) What is npm?

npm stands for node package manager. npm is a command line utility that interacts with a repository of open source projects. We can install packages, libraries and applications, along with their dependencies by using npm.

23) What is PrimeNG in Angular2?

PrimeNG: It is a collection of UI components for Angular2. It is a sibling of the popular JavaServer Faces Component Suite, PrimeFaces.

24) What is ECMAScript?

ECMAScript: It is scripting language which is used for writing server applications and services using Node.js.

25) What is Traceur in Angular2?

Traceur: It is a JavaScript compiler. This compiler is used to compile ES6 code into ES5 code. Traceur compiler supports ES5 and ES6.

26) What is ngIf in Angular2?

ngIf: It is a directive element of Angular2 that is used to add elements to the HTML code if it evaluates to true, else it will not add the elements to the HTML code.

27) Which method is used to initialize the component’s views and child views in lifecycle?

ngAfterViewInit() method.

28) What is ngAfterViewChecked() in Angular2 lifecycle?

ngAfterViewChecked(): This method is used to checks the component’s views and child views.

Leave a Comment