Skip to content

Commit 346caef

Browse files
authored
docs(docs-infra): Fix anchor link DI
Fix anchor link for Dependency Injection Overview.
1 parent dec222d commit 346caef

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

adev/src/content/guide/di/dependency-injection-context.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,29 @@ The injection context is available in these situations:
1414

1515
Knowing when you are in an injection context will allow you to use the [`inject`](api/core/inject) function to inject instances.
1616

17-
NOTE: For basic examples of using `inject()` in class constructors and field initializers, see the [overview guide](guide/di/overview#where-can-inject-be-used).
17+
NOTE: For basic examples of using `inject()` in class constructors and field initializers, see the [overview guide](/guide/di#where-can-inject-be-used).
1818

1919
## Stack frame in context
2020

2121
Some APIs are designed to be run in an injection context. This is the case, for example, with router guards. This allows the use of [`inject`](api/core/inject) within the guard function to access a service.
2222

2323
Here is an example for `CanActivateFn`
2424

25-
<docs-code language="typescript" highlight="[3]">
25+
```ts {highlight: [3]}
2626
const canActivateTeam: CanActivateFn =
27-
(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => {
28-
return inject(PermissionsService).canActivate(inject(UserToken), route.params.id);
29-
};
30-
</docs-code>
27+
(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => {
28+
return inject(PermissionsService).canActivate(inject(UserToken), route.params.id);
29+
};
30+
```
3131

3232
## Run within an injection context
3333

3434
When you want to run a given function in an injection context without already being in one, you can do so with `runInInjectionContext`.
3535
This requires access to a given injector, like the `EnvironmentInjector`, for example:
3636

37-
<docs-code header="src/app/heroes/hero.service.ts" language="typescript"
38-
highlight="[9]">
37+
```ts {highlight: [9], header"hero.service.ts"}
3938
@Injectable({
40-
providedIn: 'root',
39+
providedIn: 'root'
4140
})
4241
export class HeroService {
4342
private environmentInjector = inject(EnvironmentInjector);
@@ -48,7 +47,7 @@ export class HeroService {
4847
});
4948
}
5049
}
51-
</docs-code>
50+
```
5251

5352
Note that `inject` will return an instance only if the injector can resolve the required token.
5453

0 commit comments

Comments
 (0)