Recall & Review
beginner
What is the purpose of a shared module in Angular?
A shared module groups reusable components, directives, and pipes so they can be easily imported into other modules, avoiding code duplication.
Click to reveal answer
beginner
How do you make a component reusable across multiple Angular modules?
Declare the component in a shared module and export it. Then import that shared module wherever you want to use the component.Click to reveal answer
intermediate
Which Angular decorator is used to define a module that can export components?
The @NgModule decorator defines a module. Inside it, the 'exports' array lists components, directives, or pipes to share with other modules.
Click to reveal answer
advanced
Why should you avoid importing a shared module multiple times in Angular?
Importing a shared module multiple times can cause multiple instances of services if provided there. To avoid this, provide services in root or use the forRoot pattern.
Click to reveal answer
beginner
What is a common practice to organize reusable components in Angular projects?
Create a dedicated shared module folder with components, directives, and pipes. Export them from the shared module to keep code clean and maintainable.
Click to reveal answer
What must you do to use a reusable component from a shared module in another module?
✗ Incorrect
You import the shared module that exports the reusable component into the module where you want to use it.
Where do you list components to make them reusable in Angular?
✗ Incorrect
Components must be exported in the 'exports' array to be reusable in other modules.
What is a risk of providing services inside a shared module?
✗ Incorrect
Providing services in a shared module can cause multiple instances if the module is imported multiple times.
Which Angular feature helps avoid multiple service instances from shared modules?
✗ Incorrect
The forRoot pattern allows providing services only once, avoiding multiple instances.
What should a shared module NOT usually contain?
✗ Incorrect
Feature-specific services belong in feature modules, not shared modules.
Explain how to create and use a shared module for reusable components in Angular.
Think about how to group and share components across your app.
You got /4 concepts.
Describe the potential problem with services in shared modules and how to solve it.
Consider what happens when a module is imported in many places.
You got /3 concepts.