0
0
Angularframework~5 mins

NgModule decorator and metadata in Angular - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of the @NgModule decorator in Angular?
The @NgModule decorator defines a module in Angular. It organizes related components, directives, pipes, and services into a cohesive block, making the app easier to manage and scale.
Click to reveal answer
beginner
Name four main metadata properties inside the @NgModule decorator.
The four main metadata properties are:<br>1. declarations: Components, directives, and pipes that belong to this module.<br>2. imports: Other modules whose exported classes are needed.<br>3. providers: Services available for dependency injection.<br>4. bootstrap: The root component to start the app (usually in the root module).
Click to reveal answer
beginner
What does the declarations array in @NgModule metadata contain?
The declarations array lists components, directives, and pipes that belong to this module. These are the building blocks that the module manages and can use internally.
Click to reveal answer
beginner
Explain the role of the imports array in @NgModule.
The imports array includes other Angular modules whose exported components, directives, or pipes are needed in this module. It allows sharing features between modules.
Click to reveal answer
beginner
What is the function of the bootstrap property in @NgModule?
The bootstrap property lists the root component(s) that Angular should load when starting the app. It is usually used only in the root module to launch the main UI.
Click to reveal answer
Which @NgModule metadata property is used to declare components, directives, and pipes?
Adeclarations
Bimports
Cproviders
Dbootstrap
Where do you specify services that should be available for dependency injection in an Angular module?
Aimports
Bproviders
Cdeclarations
Dbootstrap
What is the purpose of the imports array in @NgModule?
ATo start the app
BTo list components to display
CTo register services
DTo include other modules needed
Which @NgModule property is typically used only in the root module?
Adeclarations
Bproviders
Cbootstrap
Dimports
Can you declare the same component in multiple Angular modules?
ANo, a component can only be declared in one module
BOnly if the modules are lazy loaded
CYes, but only if imported
DYes, always
Describe the role of the @NgModule decorator and its main metadata properties in Angular.
Think about how Angular organizes code into blocks.
You got /5 concepts.
    Explain why the bootstrap property is important and where it is used.
    Consider what happens when the app first loads.
    You got /3 concepts.