Bird
0
0

Which of the following is the correct syntax to define an Angular root module named AppModule?

easy📝 Syntax Q3 of 15
Angular - Modules
Which of the following is the correct syntax to define an Angular root module named AppModule?
Aexport class AppModule { } @NgModule({ declarations: [], imports: [], bootstrap: [] })
Bexport @NgModule class AppModule { declarations: [], imports: [], bootstrap: [] }
C@NgModule({ declarations: [], imports: [], bootstrap: [] }) export class AppModule { }
Dclass AppModule { } @NgModule({ declarations: [], imports: [], bootstrap: [] })
Step-by-Step Solution
Solution:
  1. Step 1: Recall Angular module syntax

    The @NgModule decorator must be placed immediately before the class definition it decorates.
  2. Step 2: Check each option for correct order and syntax

    @NgModule({ declarations: [], imports: [], bootstrap: [] }) export class AppModule { } correctly places @NgModule before export class AppModule. Other options have incorrect order or syntax.
  3. Final Answer:

    @NgModule({ declarations: [], imports: [], bootstrap: [] }) export class AppModule { } -> Option C
  4. Quick Check:

    Decorator before class = correct syntax [OK]
Quick Trick: Decorator must be right before the class [OK]
Common Mistakes:
  • Placing @NgModule after the class
  • Incorrect decorator syntax
  • Missing export keyword

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes