Codementor Events

20 Angular Interview Question.

Published Jun 01, 2021Last updated Jun 09, 2021
20 Angular Interview Question.

1. What is the Use of Angular ?
Angular is a JavaScript binding framework which bind the HTML UI and Javascript Model.This help you to reduce your effort on writing those lengthy lines of code for binding.

It also help you to build SPA (Single Page Application) by using the concept of routing. It also has lot of other feature like HTTP, Input/Output becasue of which you do not need other framework.

2. Difference between Angular And AngularJs.

Capture.PNG

3.What are Directive in Angular ?
Directive are add additional behaviour to HTML elements in our Angular application Or Directive are the Angular syntaxs which we write inside the HTML.
Directive can also change the behaviour of HTML DOM in Angular

4.What are the different kind of directive in Angular ?
3 types of Directive (SAC)

Structural Directive: Structural Directive can change the structural of DOM elements.It can add and remove the elements in DOM.
ngIf
ngFor
ngSwitch

Attributes : It change the appearance (look & feel) and behaviour of HTML elements e.g. change the color,hidden/show
Capture1.PNG

Component Directive : A component directive is a user control directive. A user can customize the component directvie.It has a template and .ts file.

5. Explain the importance of NPM and node_modules folder ?
Node Packege Manager (NPM) is help us to install any JavaScript framework in our local system

"node_modules" is the folder where all the packages are installed.
Capture3.PNG

6.Explain the importance of package.json ?
It has all the JavaScript references needed for a project. So rather then installing one package at a time we can install all packages in one go.
Capture4.PNG

7.What is TypeScript and why do we need ?
TypeScript is a superset of JavaScript. It is a strict syntactical superset of JavaScript and adds optional static typing to the language.
Capture6.PNG

It gives a nice Object Oriented enviroment which transpiles or converts to JavaScript. So, as its strongly types we will have less error and because we can do OOP(Object Oreiented Programming) with JavaScript our productivity and quality alos increases.

8. Expalin importance of Angular CLI ?
Angular CLI is a command line interface by which we can create intial Angular project template. So rather then starting form scratch we have some boiler plate code.

9. Expalin the component and module ?
In Angular component helps us to bind the view and models. where we can wirte the binding code.Components are the main building block for Angular applications

Capture.PNG

Module
Modules is logically groups of component and it also contain routing,module.ts

10. What is decorator in Angular?
Decorator is enhance the property of component.

Decorator define what kind of Angular class is it. For example if you decorate "@compoent" then it says it is a angular compoenet.
Capture.PNG

11. what is template ?
Template is an HTML view of Angular in which we can write directives. There are two ways of defining templates one is Inline and other is seperate HTML file.

12. Explain the four types of Databinding in Angular ?
Databinding in angular is how the view and component are communicate with each other.

1.Interpolation/Expression: Data flow form component to the view and we can mix the same with HTML file.
Capture1.PNG

2.Property Binding: Data flow from component to the view. It can change the property of HTML elements e.g.
propertybinding.PNG

3.Event Binding () : When you want to send event from the view to the component e.g.event.PNG

4.Two-Way Data Binding: Data flow from component to the view and vice versa.
two-way.PNG

13. Explain the term SPA ?
Single page application are application where the main UI gets loaded once and then the needed UI is loaded on demand.

14. How to implement SPA in Angular ?
Routing is a simple collection which has two things URL and Component.When this URL is called which component to load.

So routing helps you to define the navigation for your angular application. So if you want to move from one screen to other screen and you want to a Single Page Application(SPA) that means not loading and refershing the whole UI routing is needed.

15. Explain lazy loading ?
Lazy loading means on demand loading. Loading only the necessary HTML,CSS and JavaScript(ts) files so that you have better performance.

16. How can we implement lazy loading in Angular ?
Divide your project into modules use "@loadchildern" to load specific module.

Discover and read more posts from Balram Rajput
get started