Bird
0
0

Which of the following is the correct way to define an Angular module?

easy📝 Syntax Q12 of 15
Angular - Modules
Which of the following is the correct way to define an Angular module?
Aclass AppModule { @NgModule() }
Bmodule AppModule { declarations: [], imports: [] }
Cexport function AppModule() { declarations: [] }
D@NgModule({ declarations: [], imports: [], bootstrap: [] }) export class AppModule {}
Step-by-Step Solution
Solution:
  1. Step 1: Recall Angular module syntax

    Angular modules use the @NgModule decorator with metadata like declarations and imports.
  2. Step 2: Match syntax to options

    Only @NgModule({ declarations: [], imports: [], bootstrap: [] }) export class AppModule {} correctly uses @NgModule with export class syntax.
  3. Final Answer:

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

    @NgModule decorator syntax [OK]
Quick Trick: Look for @NgModule decorator with export class [OK]
Common Mistakes:
  • Using 'module' keyword instead of class
  • Placing @NgModule inside class body incorrectly
  • Defining module as a function

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes