Injection Token

A key for injecting values that aren't classes, like settings.

What is Injection Token?

An injection token lets you inject something that isn't a class, like a settings object or a string.

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

providers: [{ provide: API_URL, useValue: 'https://api.example.com' }]

private apiUrl = inject(API_URL);

Level: Freelancer · More Angular terms at this level

Updated