Bird
0
0

Find the issue in this Angular template:

medium📝 Debug Q7 of 15
Angular - Templates and Data Binding
Find the issue in this Angular template:
<img [src]="imagePath" alt="Image">

Component code:
imagePath = undefined;
ANo issue, image will not load but no error
BRuntime error because src cannot be undefined
CSyntax error in property binding
DImage will display a broken icon
Step-by-Step Solution
Solution:
  1. Step 1: Understand binding with undefined value

    Binding src to undefined means the attribute is not set.
  2. Step 2: Check Angular behavior

    Angular does not throw an error; the image simply won't load.
  3. Final Answer:

    No issue, image will not load but no error -> Option A
  4. Quick Check:

    Undefined binding does not cause errors [OK]
Quick Trick: Undefined property bindings don't cause errors, just missing data [OK]
Common Mistakes:
  • Expecting runtime errors from undefined bindings
  • Confusing syntax errors with runtime issues
  • Assuming broken image icon always shows

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes