ngIf Directive in Angular | Directives | Angular 15+
The ngIf is a structural directive. The ngIf directive is used to add or remove element from a webpage based on a given condition.
If the condition assigned to ngIf returns true, it will add the element on which it is used to the webpage. Otherwise, if the condition returnsfalse, it will remove that element from the webpage
search.component.ts
export class ProductsComponent {
variableis:any="red"
}
search.component.html
<div *ngIf="variableis=='red'">show this if variableis only red</div>