*ngIf directive is used to add or remove an element from the DOM based on a condition.
typescript
<div *ngIf="isLoggedIn">
<p>Welcome back, user!</p>
</div>
<div *ngIf="!isLoggedIn">
<p>Please log in.</p>
</div>
// component.ts
export class MyComponent {
isLoggedIn = true;
}You should see
(Since isLoggedIn is true, the text 'Welcome back, user!' will show up)