Angular & Signals (283 Qs)•Part 9: NgModules, Providers, NgZone & Injector Hierarchies (213 - 255)
What are the steps to use declaration elements?
Below are the steps to be followed to use declaration elements.
- Create the element(component, directive and pipes) and export it from the file where you wrote it
- Import it into the appropriate module.
- Declare it in the @NgModule declarations array.
Practical Code Example
typescript
// Steps to use a declarable element across modules:
// 1. Declare in Module A
// 2. Export in Module A (exports: [MyComponent])
// 3. Import Module A into Module B