What is Directive in Angular?

What is Angular Directive?

Imgur
Directive is a function that executes whenever the Angular compiler finds it in the DOM.
There are two types of directives in Angular.

  • Attribute Directive-Change the properties of HTML element when gets applied
 <div upperCase>
 <p>some text</p>
 </div>

When directive appliied it will change the text to uppercase.

  • Structural directives- Add or remove HTML elements from the DOM
    <div *ngIf="var.length>0">
     <p>Display only if var exists</p>
   </div>
Reactions

Post a Comment

0 Comments

Close Menu