Bird
0
0

Identify the error in this Angular template:

medium📝 Debug Q6 of 15
Angular - Directives
Identify the error in this Angular template:
<div [ngIf]="isVisible">Content</div>
AngIf should be used with * prefix, not as attribute binding
BngIf cannot be used on div elements
CngIf requires parentheses around the condition
DngIf must be imported from @angular/forms
Step-by-Step Solution
Solution:
  1. Step 1: Recall correct ngIf syntax

    ngIf is a structural directive and must be used with * prefix, e.g., *ngIf="condition".
  2. Step 2: Analyze given code

    The code uses [ngIf] which is invalid syntax for structural directives.
  3. Final Answer:

    ngIf should be used with * prefix, not as attribute binding -> Option A
  4. Quick Check:

    Structural directives use * prefix [OK]
Quick Trick: Use * prefix for structural directives like ngIf [OK]
Common Mistakes:
  • Using [ngIf] instead of *ngIf
  • Thinking ngIf is an attribute directive

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes