Angular 8 Interview Questions – Set 02

What is the usage of NgUpgrade in Angular 8?

The NgModules in Angular 8 is used for the following things:

  • The NgModule is a class marked by the @NgModule decorator where the @NgModule decorator is used to take a metadata object that describes how to compile a component’s template and how to create an injector at runtime.
  • The NgModules is used to configure the injector and the compiler and also help to organize the related things together.
  • The NgModule is used to identify the module’s own components, directives, and pipes. It can also make some of them public, through the exports property, to facilitate external components to use them.

What is the use of the Wildcard route in Angular 8?

In Angular 8, the Wildcard route is used to define the route of pages. You can make specific changes/updates while defining the route using Wildcard.

How can you create an app in Angular 8?

You can easily create an Angular 8 web app using Angular CLI. Type the following command to create the Angular 8 web app.

Syntax:

ng new angular_app_name
Example:

ng new myapp
The above command will create an Angular 8 app with the name “myapp.” Then, the Angular CLI will automatically install the required NPM modules. Before this, you must ensure that you have Node.js, Angular 8, and installed Angular CLI using the following command:

npm install -g @angular/cli
You can also manually create an app folder and install ng dependencies.

Which command do you use to run and load the Angular App?

Use the ng serve command to run and load the Angular App.

When was Angular 8 released, and how was it different from Angular 7?

Angular 8 was released on May 28, 2019, worldwide. It has a lot of similarity to its previous versions, such as Angular 7, except having some extensive features.

The most distinguish features of Angular 8 are:

  • Angular 8 provides differential loading for all application code.
  • Dynamic imports for lazy routes
  • Web workers
  • It provides support for TypeScript 3.4

It provides Angular Ivy as an opt-in preview which has some other advantages:

  • Generated code that is easier to read and debug at runtime
  • Faster re-build time
  • Improved payload size
  • Improved template type checking
  • Backward compatibility

What is the usage of Angular 8 ngFor Directive?

The Angular 8 ngFor directive is used to repeat a portion of the HTML template once per each item from an iterable list (Collection). The ngFor is an Angular structural directive and is similar to ngRepeat in AngularJS. Some local variables like Index, First, Last, odd, and even are exported by ngFor directive.

What is the usage of Codelyzer?

Codelyzer is an open-source tool in Angular 8 that sits on top of TSLint. It is used to check whether Angular TypeScript projects follow a set of rules or not. It also checks the errors in codes, not following pre-defined rules. It contains more than 50 rules for checking if an Angular application follows best practices. It runs on the tslint.json file and checks only the static code in Angular 8.

Codelyzer is by default inbuilt with the projects set up with the Angular command-line interface (CLI).

What is the main purpose of Angular 8 forms?

The main purpose of Angular 8 forms is to handle the user’s input. You can also use these Angular forms in your application to enable users to log in, update profiles, enter information, or perform many other data-entry tasks.

There are two approaches to handle the user’s input through forms in Angular 8:

  • Reactive forms
  • Template-driven forms
    Both approaches are used to collect user input events from the view, validate the user input, create a form model and data model to update, and provide a way to track changes.