InterviewHubPRO
Section Overview
Q129

Question 129 of 283

Part 6: Decorators, Dependency Injection & Tooling (124 - 150)

46%
Angular & Signals (283 Qs)•Part 6: Decorators, Dependency Injection & Tooling (124 - 150)

What is a DI token?

A DI token is a lookup token associated with a dependency provider in dependency injection system. The injector maintains an internal token-provider map that it references when asked for a dependency and the DI token is the key to the map. Let's take example of DI Token usage,

javascript
const BASE_URL = new InjectionToken<string>('BaseUrl');
const injector =
  Injector.create({providers: [{provide: BASE_URL, useValue: 'http://some-domain.com'}]});
const url = injector.get(BASE_URL);