Bird
0
0

What will happen if you forget to mark a component as standalone but try to lazy load it using loadComponent?

medium📝 component behavior Q5 of 15
Angular - Standalone Components
What will happen if you forget to mark a component as standalone but try to lazy load it using loadComponent?
AThe component loads normally without errors.
BAngular automatically converts it to standalone.
CThe component is lazy loaded but without its template.
DAngular throws a runtime error because the component is not standalone.
Step-by-Step Solution
Solution:
  1. Step 1: Understand standalone requirement for loadComponent

    loadComponent requires the component to be standalone to load it lazily.
  2. Step 2: Consequence of missing standalone flag

    If the component is not standalone, Angular cannot lazy load it this way and throws a runtime error.
  3. Final Answer:

    Angular throws a runtime error because the component is not standalone. -> Option D
  4. Quick Check:

    Non-standalone + loadComponent = runtime error [OK]
Quick Trick: Only standalone components can be lazy loaded with loadComponent [OK]
Common Mistakes:
  • Assuming Angular auto-converts components
  • Thinking lazy loading works without standalone
  • Believing component loads partially

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes