Skip to content

Commit 856809b

Browse files
authored
fix: update origin v16.2 (#877)
* update origin * migrate untranslated files * migrate small changes * migrate medium changes * migrate navigation * fix lint errors * fix patches * fix link errors
1 parent 3c529b3 commit 856809b

File tree

109 files changed

+1857
-3706
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+1857
-3706
lines changed

aio-ja/content/errors/NG0203.en.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
@name `inject()` must be called from an injection context
22
@category runtime
3-
@shortDescription `inject()` must be called from an injection context such as a constructor, a factory function, a field initializer, or a function used with `EnvironmentInjector#runInContext`.
3+
@shortDescription `inject()` must be called from an injection context such as a constructor, a factory function, a field initializer, or a function used with `runInInjectionContext`.
44

55
@description
6-
You see this error when you try to use the `inject()` function outside of the allowed injection context. The injection context is available during the class creation and initialization. It is also available to functions
7-
used with `EnvironmentInjector#runInContext`.
6+
You see this error when you try to use the [`inject`](api/core/inject) function outside of the allowed [injection context](guide/dependency-injection-context). The injection context is available during the class creation and initialization. It is also available to functions
7+
used with `runInInjectionContext`.
88

99
In practice the `inject()` calls are allowed in a constructor, a constructor parameter and a field initializer:
1010

@@ -23,7 +23,7 @@ export class Car {
2323
}
2424
```
2525

26-
It is also legal to call `inject` from a provider's factory:
26+
It is also legal to call [`inject`](api/core/inject) from a provider's factory:
2727

2828
```typescript
2929
providers: [
@@ -35,7 +35,7 @@ providers: [
3535
]
3636
```
3737

38-
Calls to the `inject()` function outside of the class creation or `runInContext` will result in error. Most notably, calls to `inject()` are disallowed after a class instance was created, in methods (including lifecycle hooks):
38+
Calls to the [`inject`](api/core/inject) function outside of the class creation or `runInInjectionContext` will result in error. Most notably, calls to `inject()` are disallowed after a class instance was created, in methods (including lifecycle hooks):
3939

4040
```typescript
4141
@Component({ ... })
@@ -52,7 +52,7 @@ export class CarComponent {
5252

5353
Work backwards from the stack trace of the error to identify a place where the disallowed call to `inject()` is located.
5454

55-
To fix the error move the `inject()` call to an allowed place (usually a class constructor or a field initializer).
55+
To fix the error move the [`inject`](api/core/inject) call to an allowed place (usually a class constructor or a field initializer).
5656

5757
**Note:** If you are running in a test context, `TestBed.runInInjectionContext` will enable `inject()` to succeed.
5858

@@ -68,4 +68,4 @@ TestBed.runInInjectionContext(() => {
6868

6969
<!-- end links -->
7070

71-
@reviewed 2022-05-27
71+
@reviewed 2023-04-11

aio-ja/content/errors/NG0203.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
@name `inject()` must be called from an injection context
22
@category runtime
3-
@shortDescription `inject()`は、コンストラクターやファクトリ関数、フィールド初期化、あるいは `EnvironmentInjector#runInContext` で使用される関数といった、インジェクションコンテキストから呼び出す必要があります。
3+
@shortDescription `inject()`は、コンストラクターやファクトリ関数、フィールド初期化、あるいは `runInInjectionContext` で使用される関数といった、インジェクションコンテキストから呼び出す必要があります。
44

55
@description
6-
このエラーは、許可されたインジェクションコンテキストの外で `inject()` 関数を使用しようとしたときに表示されます。インジェクションコンテキストは、クラスの作成時や初期化時に有効です。また、
7-
`EnvironmentInjector#runInContext` と共に使用される関数でも有効です。
6+
このエラーは、許可されたインジェクションコンテキストの外で [`inject`](api/core/inject) 関数を使用しようとしたときに表示されます。[インジェクションコンテキスト](guide/dependency-injection-context)、クラスの作成時や初期化時に有効です。また、
7+
`runInInjectionContext` と共に使用される関数でも有効です。
88

99
具体的には、コンストラクターやコンストラクター引数、フィールドイニシャライザで `inject()` の呼び出しが可能です:
1010

@@ -23,7 +23,7 @@ export class Car {
2323
}
2424
```
2525

26-
また、プロバイダーのファクトリーから `inject` を呼び出すこともできます:
26+
また、プロバイダーのファクトリーから [`inject`](api/core/inject) を呼び出すこともできます:
2727

2828
```typescript
2929
providers: [
@@ -35,7 +35,7 @@ providers: [
3535
]
3636
```
3737

38-
クラス作成時や `runInContext` の外で `inject()` 関数を呼び出すとエラーとなります。特に、クラスインスタンスが生成された後のメソッド(ライフサイクルフックを含む)では、`inject()`の呼び出しは禁止されています:
38+
クラス作成時や `runInInjectionContext` の外で [`inject`](api/core/inject) 関数を呼び出すとエラーとなります。特に、クラスインスタンスが生成された後のメソッド(ライフサイクルフックを含む)では、`inject()`の呼び出しは禁止されています:
3939

4040
```typescript
4141
@Component({ ... })
@@ -52,7 +52,7 @@ export class CarComponent {
5252

5353
エラーのスタックトレースから逆算して、禁止されている `inject()` の呼び出しがある場所を特定します。
5454

55-
エラーを修正するには、`inject()`の呼び出しを許可された場所(通常はクラスのコンストラクターまたはフィールド初期化時)に移します。
55+
エラーを修正するには、[`inject`](api/core/inject)の呼び出しを許可された場所(通常はクラスのコンストラクターまたはフィールド初期化時)に移します。
5656

5757
**Note:** If you are running in a test context, `TestBed.runInInjectionContext` will enable `inject()` to succeed.
5858

@@ -68,4 +68,4 @@ TestBed.runInInjectionContext(() => {
6868

6969
<!-- end links -->
7070

71-
@reviewed 2022-05-27
71+
@reviewed 2023-04-11

aio-ja/content/errors/NG05104.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
@name Root element was not found.
2+
@category runtime
3+
@shortDescription Root element was not found during bootstrap.
4+
5+
@description
6+
Boostraped components are defined in the `bootstrap` property of an `@NgModule` decorator or as the first parameter of `boopstrapApplication` for standalone components.
7+
8+
This error happens when Angular tries to boostrap one of these components but cannot find its corresponing node in the DOM.
9+
10+
@debugging
11+
12+
This issue occurs when the selector mismatches the tag
13+
14+
```typescript
15+
@Component({
16+
selector: 'my-app',
17+
...
18+
})
19+
class AppComponent {}
20+
```
21+
22+
```html
23+
<html>
24+
<app-root></app-root> <!-- Doesn't match the selector -->
25+
</html>
26+
```
27+
Replace the tag with the correct one:
28+
29+
```html
30+
<html>
31+
<my-app></my-app> <!-- OK -->
32+
</html>
33+
```

aio-ja/content/guide/angular-compiler-options.en.md

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@ For more information, see the [TypeScript Handbook](https://www.typescriptlang.o
2626

2727
The following options are available for configuring the AOT template compiler.
2828

29-
### `allowEmptyCodegenFiles`
30-
31-
When `true`, create all possible files even if they are empty.
32-
Default is `false`.
33-
Used by the Bazel build rules to simplify how Bazel rules track file dependencies.
34-
Do not use this option outside of the Bazel rules.
35-
3629
### `annotationsAs`
3730

3831
Modifies how Angular-specific annotations are emitted to improve tree-shaking.
@@ -128,9 +121,9 @@ Use to create flat modules that are packaged similarly to `@angular/core` and `@
128121
When this option is used, the `package.json` for the library should refer to the created flat module index instead of the library index file.
129122

130123
Produces only one `.metadata.json` file, which contains all the metadata necessary for symbols exported from the library index.
131-
In the created `.ngfactory.js` files, the flat module index is used to import symbols. Symbols that include both the public API from the library index as well as shrouded internal symbols.
124+
In the created `.ngfactory.js` files, the flat module index is used to import symbols. Symbols that include both the public API from the library index and shrouded internal symbols.
132125

133-
By default the `.ts` file supplied in the `files` field is assumed to be the library index.
126+
By default, the `.ts` file supplied in the `files` field is assumed to be the library index.
134127
If more than one `.ts` file is specified, `libraryIndex` is used to select the file to use.
135128
If more than one `.ts` file is supplied without a `libraryIndex`, an error is produced.
136129

aio-ja/content/guide/angular-compiler-options.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@ TypeScript 設定は、`extends` プロパティを使用して別のファイ
2626

2727
次のオプションは、AOT テンプレートコンパイラの構成に使用できます。
2828

29-
### `allowEmptyCodegenFiles`
30-
31-
`true` の場合、空であってもすべての可能なファイルを生成します。
32-
デフォルトは `false` です。
33-
Bazel ルールがファイルの依存関係を追跡する方法を単純化するために、Bazel ビルドルールで使用されます。
34-
このオプションは、Bazel ルール以外では使用しないでください。
35-
3629
### `annotationsAs`
3730

3831
ツリーシェーキングを改善するために、Angular 固有のアノテーションの出力方法を変更します。

aio-ja/content/guide/aot-metadata-errors.en.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ and be wary of new or unusual TypeScript features.
5858

5959
</div>
6060

61-
The compiler encountered a referenced to a locally defined symbol that either wasn't exported or wasn't initialized.
61+
The compiler encountered a reference to a locally defined symbol that either wasn't exported or wasn't initialized.
6262

6363
Here's a `provider` example of the problem.
6464

aio-ja/content/guide/architecture-next-steps.en.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Angular provides a framework for single-page applications, where most of the log
3333
Most applications still need to access a server using the `HttpClient` to access and save data.
3434
For some platforms and applications, you might also want to use the PWA \(Progressive Web App\) model to improve the user experience.
3535

36-
* [HTTP](guide/http): Communicate with a server to get data, save data, and invoke server-side actions with an HTTP client.
36+
* [HTTP](guide/understanding-communicating-with-http): Communicate with a server to get data, save data, and invoke server-side actions with an HTTP client.
3737
* [Server-side rendering](guide/universal): Angular Universal generates static application pages on the server through server-side rendering \(SSR\). This allows you to run your Angular application on the server in order to improve performance and show the first page quickly on mobile and low-powered devices, and also facilitate web crawlers.
3838
* [Service workers and PWA](guide/service-worker-intro): Use a service worker to reduce dependency on the network and significantly improve the user experience.
3939
* [Web workers](guide/web-worker): Learn how to run CPU-intensive computations in a background thread.

aio-ja/content/guide/architecture-next-steps.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Angular は、ほとんどのロジックやデータがクライアント側に
3333
ほとんどのアプリケーションはデータを取得、保存するために `HttpClient` を使ってサーバーにアクセスする必要があります。
3434
いくつかのプラットフォームやアプリケーションでは、PWA (Progressive Web App) モデルによってユーザー体験を改善させたいかもしれません。
3535

36-
* [HTTP](guide/http): HTTP クライアントを使用してサーバーと通信してデータを取得、保存し、サーバー側のアクションを呼び出します。
36+
* [HTTP](guide/understanding-communicating-with-http): HTTP クライアントを使用してサーバーと通信してデータを取得、保存し、サーバー側のアクションを呼び出します。
3737
* [サーバーサイドレンダリング](guide/universal): Angular Universal は、サーバーサイドレンダリング(SSR)によってサーバー上に静的アプリケーションページを生成します。これにより、パフォーマンスを向上させ、モバイルデバイスや低パワーのデバイスで最初のページをすばやく表示し、Webクローラを手助けするために、Angular アプリケーションをサーバー上で実行できます。
3838
* [Service WorkersとPWA](guide/service-worker-intro): service worker を使用してネットワークへの依存を減らしユーザー体験を大幅に改善します。
3939
* [Web workers](guide/web-worker): CPU を使う処理をバックグラウンドスレッドで走らせる方法について学びます。

aio-ja/content/guide/component-overview.en.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Angular components overview
22

3-
Components are the main building block for Angular applications.
3+
Components are the main building blocks for Angular applications.
44
Each component consists of:
55

66
* An HTML template that declares what renders on the page
@@ -98,7 +98,7 @@ Every component requires a CSS *selector*. A selector instructs Angular to insta
9898
For example, consider a component `hello-world.component.ts` that defines its selector as `app-hello-world`.
9999
This selector instructs Angular to instantiate this component any time the tag `<app-hello-world>` appears in a template.
100100

101-
Specify a component's selector by adding a `selector` statement to the `@Component` decorator.
101+
Specify a component's selector by adding a `selector` property to the `@Component` decorator.
102102

103103
<code-example path="component-overview/src/app/component-overview/component-overview.component.ts" region="selector"></code-example>
104104

@@ -123,7 +123,7 @@ For example:
123123
<div class="alert is-helpful">
124124

125125
An Angular component requires a template defined using `template` or `templateUrl`.
126-
You cannot have both statements in a component.
126+
You cannot have both properties in a component.
127127

128128
</div>
129129

@@ -155,4 +155,4 @@ The `styles` property takes an array of strings that contain the CSS rule declar
155155

156156
<!-- end links -->
157157

158-
@reviewed 2022-02-28
158+
@reviewed 2023-07-29

aio-ja/content/guide/component-overview.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Angular コンポーネントの概要 {@a angular-components-overview}
22

3-
コンポーネントは Angular アプリケーションの主な構成要素です。各コンポーネントは次のように構成されています。
3+
コンポーネントは Angular アプリケーションの主な構成要素です。
4+
各コンポーネントは次のように構成されています。
45

56
* ページに表示するものを宣言する HTML テンプレート
67
* 振る舞いを定義する Typescript クラス
@@ -25,7 +26,8 @@
2526

2627
## コンポーネントの作成 {@a creating-a-component}
2728

28-
コンポーネントを作成するもっとも簡単な方法は Angular CLI です。手動でコンポーネントを作成することもできます。
29+
コンポーネントを作成するもっとも簡単な方法は Angular CLI です。
30+
手動でコンポーネントを作成することもできます。
2931

3032
### Angular CLI を使ったコンポーネントの作成 {@a creating-a-component-using-the-angular-cli}
3133

@@ -112,7 +114,7 @@ Angular CLI は Angular コンポーネントを作成するもっとも簡単
112114

113115
すべてのコンポーネントには CSS _セレクタ_ が必要です。セレクターは HTML テンプレートの中で対応するタグを見つけたらどこでも、そのコンポーネントをインスタンス化するように Angular に指示します。たとえば、`hello-world.component.ts``app-hello-world` というセレクターを定義しているコンポーネントを考えてみましょう。このセレクターは、テンプレートに `<app-hello-world>` タグが現れるたびに、このコンポーネントのインスタンスを作成するように Angular に指示します。
114116

115-
コンポーネントのセレクターを指定するには、`@Component` デコレーターに `selector` 文を追加します
117+
コンポーネントのセレクターを指定するには、`@Component` デコレーターに `selector` プロパティを追加します
116118

117119
<code-example
118120
path="component-overview/src/app/component-overview/component-overview.component.ts"
@@ -148,7 +150,7 @@ Angular CLI は Angular コンポーネントを作成するもっとも簡単
148150

149151
<div class="alert is-helpful">
150152

151-
Angular コンポーネントは、`template` または `templateUrl` で定義されたテンプレートを必要とします。コンポーネントの中で両方の記述をもつことはできません
153+
Angular コンポーネントは、`template` または `templateUrl` で定義されたテンプレートを必要とします。コンポーネントの中で両方のプロパティをもつことはできません
152154

153155
</div>
154156

@@ -180,4 +182,4 @@ Angular コンポーネントは、`template` または `templateUrl` で定義
180182
* コンポーネントのスタイルについては、[コンポーネントスタイル](guide/component-styles)を参照してください
181183
* テンプレートの詳細については、[テンプレート構文](guide/template-syntax)を参照してください
182184

183-
@reviewed 2021-03-18
185+
@reviewed 2023-07-29
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Injection context
2+
3+
The dependency injection (DI) system relies internaly on a runtime context where the current injector is available.
4+
This means that injectors can only work when code is executed in this context.
5+
6+
The injection context is available in these situations:
7+
8+
* Construction (via the `constructor`) of a class being instantiated by the DI system, such as an `@Injectable` or `@Component`.
9+
* In the initializer for fields of such classes.
10+
* In the factory function specified for `useFactory` of a `Provider` or an `@Injectable`.
11+
* In the `factory` function specified for an `InjectionToken`.
12+
* Within a stack frame that is run in a injection context.
13+
14+
Knowing when your are in an injection context, will allow you to use the [`inject`](api/core/inject) function to inject instances.
15+
16+
## Class constructors
17+
18+
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.
19+
20+
<code-example language="typescript">
21+
class MyComponent {
22+
private service1: Service1;
23+
private service2: Service2 = inject(Service2); // In context
24+
25+
constructor() {
26+
this.service1 = inject(HeroService) // In context
27+
}
28+
}
29+
</code-example>
30+
31+
## Stack frame in context
32+
33+
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.
34+
35+
Here is an example for `CanActivateFn`
36+
<code-example format="typescript" language="typescript">
37+
const canActivateTeam: CanActivateFn =
38+
(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => {
39+
return inject(PermissionsService).canActivate(inject(UserToken), route.params.id);
40+
};
41+
</code-example>
42+
43+
## Run within an injection context
44+
45+
When you want to run a given function in an injection context without being in one, you can do it with `runInInjectionContext`.
46+
This requires to have access to a given injector like the `EnvironmentInjector` for example.
47+
48+
<code-example path="dependency-injection/src/app/heroes/hero.service.5.ts" region="run-in-context" header="src/app/heroes/hero.service.ts">
49+
</code-example>
50+
51+
Note that `inject` will return an instance only if the injector can resolve the required token.
52+
53+
## Asserts the context
54+
55+
Angular provides `assertInInjectionContext` helper function to assert that the current context is an injection context.
56+
57+
## Using DI outside of a context
58+
59+
Calling [`inject`](api/core/inject) or calling `assertInInjectionContext` outside of an injection context will throw [error NG0203](/errors/NG0203).
60+
61+
62+
63+
@reviewed 2023-04-11

0 commit comments

Comments
 (0)