Date:

Share:

What Are Directives in Angular.

Related Articles

What are directives in Angular?

In this article we will learn about the directive built into Angular. This is a custom HTML attribute that changes the behavior of the DOM element and changes the DOM style. In other words, we can say that it is used to extend the power of the DOM elements.

Types of guidelines at an angle?
  1. Structural guidance.
  2. component instruction.
  3. attribute teaching.
1. Structural instruction.

Structure directives manipulate the DOM elements. These instructions have a * sign before the instruction. For example, *ngIf and *ngFor.

Example:

2. Teaching components.

Special directives in Angular are called Components because this type of directive has a template or template URLs. In fact, it’s a component directive that shows something in the DOM.

3. Feature guidance.

The attribute directive is used to change the appearance and behavior of DOM elements. For example, the ngClass directive, the ngStyle directive, etc.

  • ngClass directive: The ngClass directive is used to add or remove CSS classes to an HTML element.
  • ngStyle directive: The ngStyle directive allows you to change the style of an HTML element using the expression. You can also use the ngStyle directive to dynamically change the style of your HTML element.

A quiz app in Angular. Client-side PDF generation in Angular with jsPDF.

Source

Popular Articles