Top 10 Angular Interview Questions & Answers 2021

Q1) What is Angular?

  1. Angular could help you to make your application development faster.
  2. Angular combine different technologies and provide you a good platform.
  3. You can create a bigger-level application very smoothly with respect to scalability, security, and performance.
  4. Angular is a building framework that binds view with the model. For example, in jQuery, to work with the textbox, $(#textbox1.text).
  5. In jQuery, so many codes required to connect our model to the view, for example, focus not focus and many more.
  6. To perform binding, angular will reduce the line of code.

Q2) What is characteristic of Single page applications in Angular?

  1. The site must be served over HTTPS.
  2. Pages must be responsive on mobile and tablets, you can use the bootstrap to do it.
  3. All app URLs should load while offline. If you are on the HOME page, turn off your internet, refresh your page, your app render without any problem. Of course, if you are searching for something from API, may not display any result. But you can receive any error message that you don’t have an internet connection.
  4. Metadata should be provided on the home screen. This is applicable for a mobile device even on a desktop.
  5. The first load must be fast even on a 3G network. You can achieve this by using Lazy Loading.
  6. The site must work on different browsers in the same manner.
  7. Each page should have URL.

Q3) Explain the history of Angular?

Angular came up with series of versions. Angular 1.X, which is normally termed AngularJS.
Later whatever the version release Angular 2.x, Angular 3.x, and so on, termed Angular.

There are the following differences between Angular 2 +, and Angular 1.x

Angular JS (1.X)Angular (2.X +)
Supported languages JavascriptSupported languages Typescript
Based on ControllerBased on Component
Not built with mobile-first Mobile complaint
Does not support Angular CLISupport Angular CLI
Run-on only client-sideRuns- on client-side & server-side
Does not support lazy loadingSupport lazy loading
Does not support SEOSupport SEO
Initialize: – Using angular.bootstrap() and
ng-app function.
Initialize: – Using bootstrapModule() function
Support filtersSupport Pipe
Some extra point:-
• Developed in 2009 by Misko Hevery and Adam Abrons at Brat Tech
• Misko Hevery started to work for Google in 2009
• Angular version 1.0 (AngularJS) was released in 2012 by Google
• Angular version 2.0 was released in September 2016
• Angular 4.0 was released in March 2017
• Angular 5.0 was released in Nov 2017
• Angular 6.0 was released in May 2018
• Angular 7.0 was released in Oct 2018
• Angular 8.0 was released in May 2019
• Angular 9.0 was released in Feb 2020

Q4) Why do we need to use and learn Angular?

  • The first and foremost important thing Angular is supported by Google and fully open-source.
  • Excellent community support
  • Angular support SPA Functionality.
  • Easy to implement Dependency Injection.
  • Support MVC (Model View Controller) architecture.
  • Angular support Typescript and ES6 standard.
  • Enable testing using jasmine and karma

Q5) How to enable Ivy into the older versions of Angular i.e. < 9?

A) Open tsconfig.app.json, and after the configuration, enable IVY with the specific code as specified below.

"angularCompilerOptions": {
"enableIvy": true
}

In the older version, we have to enable the Ivy rendering engine manually.

Q6) What is the IVY engine in Angular? When it was released? What are the features of Ivy?

A) Currently, Google is majorly focusing on reducing the file size of our project. IVY was released in Angular 9. It is a compiler and a runtime engine.

it is used to run the Angular app with the smallest bundle size that directly improves the build performance.

In the older version, we have to enable it manually but from version 9, the angular Ivy rendering engine is now a default feature.

Features

  • Most IMP: – Smaller bundle size
  • Enabling AOT on by default
  • Improvement in style binding
  • Debugging and testing is faster
  • Improvements in Internationalization, build time and errors

Q7) How to change the default port number other than 4200 in Angular?

ng serve --port 4300

Q8) How to change the default protocol other than HTTP in Angular?

By default, the Angular application works on HTTP protocol. Yes, we can change it to HTTPS which is an encrypted connection between client and server.

We have to specify the additional flag along with command ng serve, which is –SSL, and we can enable it using Boolean value true/false.

ng serve --ssl=true

Q9) How to add PWA Features to your server?

ng add @angular/pwa

It will download the general dependency and update your application.

Q10) Explain the Angular code

import { Injectable } from '@angular/core';

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

  constructor() { }
}

Class is created and decorated with,

@Injectable({
providedIn: 'root'
})

@Injectable has providedin root, which means that it will automatically become the part of the root module.

({
providedIn: 'root'
})

If the above code will not present then,

@Injectable()

The service class is not part of any module, manually inject it into your app.module.ts file (Provider[ ])

Q11) How do I deploy an angular app to Firebase?

npm install -g firebase-tools
firebase --help
https://firebase.google.com/

Open the website and create a new project.

ng build
firebase login
firebase init
Are you ready to proceed? (Y/n) : - Y
firebase upload
Spacebar
Enter Key
What do you want to use as your public directory? (public) :- dist/yourFolderName

Copy folder name from: – Angular.json file (dist/yourFolderName)

"outputPath": "dist/yourFolderName",
Configure as a single-page app (rewrite all urls to /index.html) Y
Set up automatic builds and deploys with GitHub? (y/N) N
File dist/... already exists. Overwrite? (y/N) :- N
firebase deploy

Q12) How do I create a service file in angular 10?

ng g s services/yourServiceName

For more, Angular interview questions and answers: – Angular Interview question series part 1

Leave a Comment