CodeZettaInterview Hub

Angular · Dependency Injection · Junior · Comparison

What are InjectionToken and multi providers?

Short Interview Answer

InjectionToken identifies non-class dependencies; multi: true collects an array of providers.

Detailed Explanation

Use tokens for config objects and interfaces. HTTP_INTERCEPTORS is a classic multi provider. Prefer opaque tokens over string tokens.

Example

export const API_URL = new InjectionToken<string>('API_URL');

Did you know this answer?