Complete the code to show the paragraph only if isVisible is true.
<p *[1]="isVisible">This text is conditionally visible.</p>
The *ngIf directive in Angular conditionally includes or excludes an element based on the expression. Here, it shows the paragraph only if isVisible is true.
Complete the code to display the message only when user.isLoggedIn is true.
<div *[1]="user.isLoggedIn">Welcome back!</div>
*ngIf checks the condition and renders the element only if user.isLoggedIn is true.
Fix the error in the code to conditionally show the button when showButton is true.
<button *[1]="showButton">Click me</button>
The correct directive for conditional rendering is *ngIf. *ngShow and *ngRepeat are not valid Angular directives.
Fill both blanks to show the div only if isAdmin is true and add a CSS class highlight.
<div *[1]="isAdmin" [class.[2]]="isAdmin">Admin Panel</div>
*ngIf conditionally renders the div. The [class.highlight] adds the CSS class highlight when isAdmin is true.
Fill all three blanks to display a message only if user.isActive is true, show the username, and add a CSS class active-user.
<p *[1]="user.isActive" [class.[2]]="user.isActive">Hello, [3]</p>
*ngIf conditionally renders the paragraph. The [class.active-user] adds the CSS class when user.isActive is true. The interpolation {{user.name}} shows the username.