AngularJS Interview Questions and Answers
Tags: angularjainterview, angularjstutorials, angular6training
Published: 2018-08-22 10:56:09

---
title: AngularJS Interview Questions and Answers
published: True
description: 
tags: Angularja Interview, Angularjs Tutorials, Angular 6 Training,

---

Q1. Explain component life cycle in Angular?
 

In Angular component life cycle in Angular goes through the following stages.

Create

Render

Create and render children

Check for bound data changes and re-render

Destroy

 

Q2. List the types of Data Binding supported by Angular5?
 

Angular 5 supports four types of Data Binding They are

String Interpolation

Property Binding

Event Binding

Two-way-binding

 

Q3. What are the new features of Angular 2 ?
 

Angular 2 is a platform that encompasses a wide range of capabilities. Some new features were added in Angular 2 which includes:

Universal server rendering- It is the library which is used to make building universal apps a smooth experience. It is an important feature of Angular 2.
A mobile toolkit- It provides all the mobile toolkit and techniques to build high-performance mobile applications. The web applications which are developed using the mobile toolkit can be loaded on any device with or without internet connection which is a great advantage.

A command line interface-it can generate components, routes, services, and pipes with the help of commands.

 

Q4. How do you define the transition between two states in angular?
 

Transitions between two states take place so that we can build simple animations between two states driven by a model attribute. Transition basically means navigating from the current state to a new state. In angular, the transition is an animation-specific function which is used in angular’s animation DSL language. Transition declares the sequence of animation steps that will be executed when entered value is satisfied. A function is provided an argument for a transition and it will be executed each time a state change occurs. In this, if the function is true, then the animation will run else it won’t get executed.

 

Q5. What is the difference between observable and promises?
 

The differences between observable and promises are:-

Observable is a more powerful way of handling HTTP asynchronous requests. Whereas, A promise handles a single event when an asynchronous operation completes or fails.

An observable is like a stream which allows passing zero or more events where the callback is called for each event. Whereas, A promise eventually calls the success or failed callback even when you don’t need the notification or the result it provides anymore.

Observable works with multiple values for a particular time. Whereas, Promises works with and even returns a single value at a time.

Observables can be canceled. Whereas, Promises cannot be canceled.

Observable supports map, filter, reduce and similar operators. Whereas, Promises have more readable codes with try/catch and async/await.

In observable, one operator ‘retry’ can be used to retry whenever needed. Whereas, Promises cannot be retried. A promise should have access to the original function that returned the promise in order to have a retry capability.

 

Q6. What is ECMAScript?
 

ECMAScript is a standard for scripting languages. It is a subset of Javascript. Languages such as ActionScript, JavaScript use ECMAScript as its core. ECMA stands for European Computer Manufacturer’s Association. Coders commonly use ECMAScript for client-side scripting on the World Wide Web. It is also used for server applications and services. It includes structured, dynamic, functional, and prototype-based features. The ECMAScript was developed by Brendan Eich of Netscape. The ECMAScript is standardized by the ECMA international standards organization in the ECMA-262 and ECMA-402 specifications. It is a programming language which is designed specifically for acting on an existing entity or system. It provides the rules, details, and guidelines that a scripting language must observe to be considered ECMAScript compliant.

 

Q7. List the key components of Angular 2?
 

The Angular 2 comprises of the following key components:

Module – This is used to break the application into the logical pieces of the program code and each piece of code or module is designed to perform a single and unique task.

Component – This is used to bring the modules together.

Templates – This is used to define the Views of an Angular JS application.

Metadata – This is used to add more data to an Angular JS application.

Service – This component is used to develop the components, which can be used to share in the entire application.

 

Q8. Explain the component directory structure of Angular 4 
 

Here are the elements which are present in the component directory structure anf modules:-

module.ts- in this, the angular module is declared. @NgModule decorator is used which initializes the different aspects of angular applications. AppComponent is also declared in it.

components.ts- it simply defines the components in angular and this is the place where the app-root sector is also defined. A title attribute is also declared in the component.

component.html- it is the template file of the application which represents the visual parts of our components.