0
0
Angularframework~5 mins

Declarations, imports, and exports in Angular - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of declarations in an Angular module?
Declarations list the components, directives, and pipes that belong to that module. They tell Angular what this module owns and can use internally.
Click to reveal answer
beginner
Why do we use imports in an Angular module?
Imports bring in other Angular modules so you can use their exported components, directives, or pipes inside your module. It's like borrowing tools from a friend’s toolbox.
Click to reveal answer
beginner
What does exports do in an Angular module?
Exports make components, directives, or pipes available to other modules that import this module. It’s like sharing your toys so others can play with them.
Click to reveal answer
intermediate
Can a component be declared in more than one Angular module?
No, a component can only be declared in one module. Declaring it in multiple modules causes errors because Angular wouldn’t know which one owns it.
Click to reveal answer
intermediate
How do imports and exports work together in Angular modules?
A module imports another module to use what it exports. The exporting module shares its components/directives/pipes, and the importing module can then use them inside its templates.
Click to reveal answer
What should you put inside the declarations array of an Angular module?
AComponents, directives, and pipes that belong to this module
BOther Angular modules to use
CServices to inject
DCSS stylesheets
If you want to use a component from another module, what must you do?
ADeclare the component again in your module
BImport the module that exports that component
CAdd the component to your exports array
DNothing, Angular finds it automatically
What happens if you declare the same component in two different Angular modules?
AThe component is ignored in the second module
BThe component works in both modules
CAngular throws an error
DAngular merges the declarations
Which array in an Angular module controls what is shared with other modules?
Aproviders
Bimports
Cdeclarations
Dexports
To use Angular's built-in directives like *ngIf, what must you do?
AImport CommonModule in your module
BDeclare NgIf in your declarations
CExport NgIf from your module
DNothing, they are always available
Explain how declarations, imports, and exports work together in Angular modules.
Think of declarations as what you own, imports as what you borrow, and exports as what you share.
You got /3 concepts.
    Describe what happens if you forget to export a component you want to use in another module.
    Sharing requires explicit export.
    You got /3 concepts.