inject()
noun
say it: “in-JEKT” /ɪnˈdʒɛkt/
The Angular function a class calls to ask for a service.
What does inject() do?
inject() is the function that asks Angular's dependency injection for a service. It is the modern alternative to constructor parameters.
export class Profile {
private http = inject(HttpClient);
private route = inject(ActivatedRoute);
}
In a sentence
- “calculator = inject(PriceCalculator) gives the component the shared calculator.”
Level: Apprentice · More Angular terms at this level
Updated