What is Directive in Angular?


Imgur
The 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 the HTML element when it gets applied
 <div upperCase>
 <p>some text</p>
 </div>

When a directive applied, it will change the text to uppercase.$ads={1}

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

Please do not post any spam link in the comment box😊

Post a Comment (0)
Previous Post Next Post