From 490786af1079f8e9867ff5cc45edfebfee8fb155 Mon Sep 17 00:00:00 2001 From: Lang Date: Mon, 16 Sep 2024 23:25:49 +0200 Subject: [PATCH] docs: complete the example in use InjectionToken section (#57839) PR Close #57839 --- .../content/guide/di/dependency-injection-providers.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/adev/src/content/guide/di/dependency-injection-providers.md b/adev/src/content/guide/di/dependency-injection-providers.md index e8065ff70b4..afd9575b674 100644 --- a/adev/src/content/guide/di/dependency-injection-providers.md +++ b/adev/src/content/guide/di/dependency-injection-providers.md @@ -161,6 +161,10 @@ The following example defines a token, `APP_CONFIG`. of the type `InjectionToken import { InjectionToken } from '@angular/core'; +export interface AppConfig { + title: string; +} + export const APP_CONFIG = new InjectionToken('app.config description'); @@ -169,6 +173,10 @@ The optional type parameter, ``, and the token description, `app.conf Next, register the dependency provider in the component using the `InjectionToken` object of `APP_CONFIG`: +const MY_APP_CONFIG_VARIABLE: AppConfig = { + title: 'Hello', +}; + providers: [{ provide: APP_CONFIG, useValue: MY_APP_CONFIG_VARIABLE }]