Complete the code to use a structural directive that conditionally shows a paragraph.
<p *[1]="isVisible">This paragraph is conditionally visible.</p>
The ngIf directive is a structural directive that adds or removes elements based on a condition.
Complete the code to apply a CSS class conditionally using an attribute directive.
<div [[1]]="isActive ? 'active' : ''">Content here</div>
The ngClass directive is an attribute directive that adds or removes CSS classes based on conditions.
Fix the error in the code to correctly use a structural directive for looping over items.
<li *ngFor="let item of [1]">{{item}}</li>
The ngFor directive expects an iterable variable, not a function call or invalid syntax.
Fill both blanks to create a structural directive that shows a message only if the user is logged in.
<div *[1]="[2]">Welcome back!</div>
The ngIf directive conditionally shows the element when isLoggedIn is true.
Fill all three blanks to create a dictionary comprehension that maps item names to their lengths only if length is greater than 3.
const lengths = { [1]: [2].length for [1] of items if [2].length > 3 };This code uses item as the variable for each element in items. It maps item names to their lengths if the length is greater than 3.