Friday, March 19, 2021

PART-5 INTERVIEW TYPE QUESTIONS

1. What are three different types of directives and explain them with example?

Three three types of directives in Angular and these are :

Structural Directive: Structural directives enable Angular developers to add, edit and remove elements in the DOM.

Attribute Directive: Attribute directive enable Angular developers to define an attribute that when added to an element change the appearance of the element.

Component Directive: This enables you to define directives that contain templates using a rich HTML-like Syntax.

2. What is Refactoring?

Refactoring is the technique for restructuring an existing body of code, altering its internal structure without changing its external behavior.

3. Explain ng generate?

ng generate takes the name of the project, as specified in the projects section of the angular.json workspace configuration file. When a project name is not supplied, it will execute for all projects.

4. What is Dependency injection?

Dependency injection makes testing easier . The injection can be done through constructor.

5. How to navigate from within the component code?

The navigate from within the component code is done by following syntax:

        this.router.navigate(['/admin]);

6. What is a constructor in a class?

A constructor in Java is a special method that is used to initialize objects. The constructor is called when an object of a class is created. But in case of TypeScript only constructor() keyword is used to create a constructor.

7. What is the syntax for ngFor Loop?

The syntax for ngFor Loop is as below:

<ul>

    <li  *ngFor=" let item of items; let i= index">

{{i}}     {{item}}

</li>

</ul>




0 comments:

Post a Comment