mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
docs: correct formatting in dependency injection guides
This commit is contained in:
committed by
Jessica Janiuk
parent
e87f423d90
commit
61066071cf
@@ -705,7 +705,7 @@ export class ModalComponent { }
|
||||
- Must be provided wherever needed
|
||||
- Always included in the same JavaScript bundle as the component or directive, even if the value is never injected
|
||||
|
||||
Note: If multiple directives on the same element provide the same token, one will win, but which one is undefined.
|
||||
NOTE: If multiple directives on the same element provide the same token, one will win, but which one is undefined.
|
||||
|
||||
### Route providers
|
||||
|
||||
|
||||
@@ -37,16 +37,16 @@ This requires access to a given injector, like the `EnvironmentInjector`, for ex
|
||||
<docs-code header="src/app/heroes/hero.service.ts" language="typescript"
|
||||
highlight="[9]">
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class HeroService {
|
||||
private environmentInjector = inject(EnvironmentInjector);
|
||||
private environmentInjector = inject(EnvironmentInjector);
|
||||
|
||||
someMethod() {
|
||||
runInInjectionContext(this.environmentInjector, () => {
|
||||
inject(SomeService); // Do what you need with the injected service
|
||||
});
|
||||
}
|
||||
someMethod() {
|
||||
runInInjectionContext(this.environmentInjector, () => {
|
||||
inject(SomeService); // Do what you need with the injected service
|
||||
});
|
||||
}
|
||||
}
|
||||
</docs-code>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user