Friday, 19 March 2021

Built in Structural Directives

*ngIf - ngIf is used to display or hide the DOM Element based on the expression value assigned to it. The expression value may be either true or false.

*ngIf-else - ngIf-else works like a simple If-else statement, wherein if the condition is true then ‘If’ DOM element is rendered, else the other DOM Element is rendered. Angular uses ng-template with element selector in order to display the else section on DOM.

*ngFor - *ngFor is used to loop through the dynamic lists in the DOM. Simply, it is used to build data presentation lists and tables in HTML DOM.

*ngSwitch - ngSwitch is used to choose between multiple case statements defined by the expressions inside the *ngSwitchCase and display on the DOM Element according to that. If no expression is matched, the default case DOM Element is displayed. 

No comments:

Post a Comment