Angular · Junior · Question 31 of 75
Where can inject() be called?
- ✓Correct answer: In an injection context: field initializers, the constructor, provider factories and similar places
- 2Anywhere, including inside click handlers and
setTimeoutcallbacks - 3Only inside
ngOnInit
Explanation
Calling inject() in an event handler throws NG0203. Inject dependencies once at construction and use them later in methods.