Course lesson
Bind an Angular Signal Effect to an Injector for Automatic Cleanup
In Angular, effects are often assigned to class properties during the constructor phase. However, there may be cases where the effect needs to be parameterized with values from parent components, which are not available during construction.
- Duration
- 2 min
- Access
- Free
- Transcript
- Retained from source evidence
In Angular, effects are often assigned to class properties during the constructor phase. However, there may be cases where the effect needs to be parameterized with values from parent components, which are not available during construction.
When running effects outside the constructor, such as in the ngOnInit lifecycle hook, you need to manually provide the injector instance to the effect configuration.