forked from angular/angular-ja
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: update origin v16.2 (angular#877)
* update origin * migrate untranslated files * migrate small changes * migrate medium changes * migrate navigation * fix lint errors * fix patches * fix link errors
- Loading branch information
Showing
109 changed files
with
1,857 additions
and
3,706 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
@name Root element was not found. | ||
@category runtime | ||
@shortDescription Root element was not found during bootstrap. | ||
|
||
@description | ||
Boostraped components are defined in the `bootstrap` property of an `@NgModule` decorator or as the first parameter of `boopstrapApplication` for standalone components. | ||
|
||
This error happens when Angular tries to boostrap one of these components but cannot find its corresponing node in the DOM. | ||
|
||
@debugging | ||
|
||
This issue occurs when the selector mismatches the tag | ||
|
||
```typescript | ||
@Component({ | ||
selector: 'my-app', | ||
... | ||
}) | ||
class AppComponent {} | ||
``` | ||
|
||
```html | ||
<html> | ||
<app-root></app-root> <!-- Doesn't match the selector --> | ||
</html> | ||
``` | ||
Replace the tag with the correct one: | ||
|
||
```html | ||
<html> | ||
<my-app></my-app> <!-- OK --> | ||
</html> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Injection context | ||
|
||
The dependency injection (DI) system relies internaly on a runtime context where the current injector is available. | ||
This means that injectors can only work when code is executed in this context. | ||
|
||
The injection context is available in these situations: | ||
|
||
* Construction (via the `constructor`) of a class being instantiated by the DI system, such as an `@Injectable` or `@Component`. | ||
* In the initializer for fields of such classes. | ||
* In the factory function specified for `useFactory` of a `Provider` or an `@Injectable`. | ||
* In the `factory` function specified for an `InjectionToken`. | ||
* Within a stack frame that is run in a injection context. | ||
|
||
Knowing when your are in an injection context, will allow you to use the [`inject`](api/core/inject) function to inject instances. | ||
|
||
## Class constructors | ||
|
||
Everytime the DI system instantiates a class, this is done in an injection context. This is being handled by the framework itself. The constructor of the class is executed in that runtime context thus allowing to inject a token using the [`inject`](api/core/inject) function. | ||
|
||
<code-example language="typescript"> | ||
class MyComponent { | ||
private service1: Service1; | ||
private service2: Service2 = inject(Service2); // In context | ||
|
||
constructor() { | ||
this.service1 = inject(HeroService) // In context | ||
} | ||
} | ||
</code-example> | ||
|
||
## Stack frame in context | ||
|
||
Some APIs are designed to be run in an injection context. This is the case, for example, of the router guards. It allows the use of [`inject`](api/core/inject) to access a service within the guard function. | ||
|
||
Here is an example for `CanActivateFn` | ||
<code-example format="typescript" language="typescript"> | ||
const canActivateTeam: CanActivateFn = | ||
(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => { | ||
return inject(PermissionsService).canActivate(inject(UserToken), route.params.id); | ||
}; | ||
</code-example> | ||
|
||
## Run within an injection context | ||
|
||
When you want to run a given function in an injection context without being in one, you can do it with `runInInjectionContext`. | ||
This requires to have access to a given injector like the `EnvironmentInjector` for example. | ||
|
||
<code-example path="dependency-injection/src/app/heroes/hero.service.5.ts" region="run-in-context" header="src/app/heroes/hero.service.ts"> | ||
</code-example> | ||
|
||
Note that `inject` will return an instance only if the injector can resolve the required token. | ||
|
||
## Asserts the context | ||
|
||
Angular provides `assertInInjectionContext` helper function to assert that the current context is an injection context. | ||
|
||
## Using DI outside of a context | ||
|
||
Calling [`inject`](api/core/inject) or calling `assertInInjectionContext` outside of an injection context will throw [error NG0203](/errors/NG0203). | ||
|
||
|
||
|
||
@reviewed 2023-04-11 |
Oops, something went wrong.