Bird
0
0

What is wrong with this AppModule snippet?

medium📝 Debug Q7 of 15
Angular - Modules
What is wrong with this AppModule snippet?
@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule],
  bootstrap: []
})
export class AppModule { }
ABrowserModule should be in providers array.
BAppComponent should be in imports array.
CBootstrap array cannot be empty in root module.
DDeclarations array cannot have components.
Step-by-Step Solution
Solution:
  1. Step 1: Understand bootstrap array role

    The bootstrap array defines the root component to load when the app starts.
  2. Step 2: Check consequences of empty bootstrap

    If bootstrap is empty, Angular does not know which component to load first, causing the app to fail.
  3. Final Answer:

    Bootstrap array cannot be empty in root module. -> Option C
  4. Quick Check:

    Bootstrap must have root component [OK]
Quick Trick: Bootstrap array must include root component [OK]
Common Mistakes:
  • Leaving bootstrap empty
  • Putting components in imports
  • Misusing providers for modules

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes