diff --git a/adev-ja/src/app/features/home/home.component.en.html b/adev-ja/src/app/features/home/home.component.en.html index 4e55dce261..5d6445209c 100644 --- a/adev-ja/src/app/features/home/home.component.en.html +++ b/adev-ja/src/app/features/home/home.component.en.html @@ -13,7 +13,7 @@
Warning: @@ -61,7 +61,7 @@
Warning: @@ -70,7 +70,7 @@
Warning: @@ -84,19 +84,19 @@
Shows information for all Angular developers.
- } @else if (level === 2) { + } @else if (level() === 2) {Shows information that's of interest to more advanced Angular developers.
- } @else if (level === 3) { + } @else if (level() === 3) {Shows all the information we have about this update.
} @@ -111,7 +111,7 @@警告: @@ -61,7 +61,7 @@
警告: @@ -70,7 +70,7 @@
警告: @@ -84,19 +84,19 @@
すべてのAngular開発者向けの情報を表示します。
- } @else if (level === 2) { + } @else if (level() === 2) {より上級のAngular開発者向けの情報を表示します。
- } @else if (level === 3) { + } @else if (level() === 3) {このアップデートに関するすべての情報を表示します。
} @@ -111,7 +111,7 @@
User: {{user().name}}
', + template: 'User: {{user.name}}
', }) export class UserProfile { private userService = inject(UserClient); // ERROR: No provider @@ -765,7 +766,7 @@ import {UserClient} from './user-client'; @Component({ selector: 'app-profile', - template: 'User: {{user().name}}
', + template: 'User: {{user.name}}
', }) export class UserProfile { private userService = inject(UserClient); // Works: providedIn: 'root' @@ -778,16 +779,14 @@ export class UserProfile { The dependency path in the error message shows the chain of injections that led to the failure. ``` -NullInjectorError: No provider for LoggerStore! - Dependency path: App -> DataStore -> ApiClient -> LoggerStore +NG0201: No provider found for `LoggerStore`. Path: DataStore -> ApiClient -> LoggerStore. ``` This path tells you: -1. `App` injected `DataStore` -2. `DataStore` injected `ApiClient` -3. `ApiClient` tried to inject `LoggerStore` -4. No provider for `LoggerStore` was found +1. `DataStore` injected `ApiClient` +2. `ApiClient` tried to inject `LoggerStore` +3. No provider for `LoggerStore` was found Start your investigation at the end of the chain (`LoggerStore`) and verify it has proper configuration. @@ -818,9 +817,10 @@ Optional injection returns `null` if no provider is found, allowing you to handl This error occurs when you call `inject()` outside of a valid injection context. Angular requires `inject()` to be called synchronously during class construction or factory execution. ``` -NG0203: inject() must be called from an injection context such as a -constructor, a factory function, a field initializer, or a function -used with `runInInjectionContext`. +NG0203: The `UserClient` token injection failed. `inject()` function must +be called from an injection context such as a constructor, a factory +function, a field initializer, or a function used with +`runInInjectionContext`. ``` #### Valid injection contexts @@ -835,7 +835,7 @@ Angular allows `inject()` in these locations: @Component({ selector: 'app-profile', - template: 'User: {{user().name}}
', + template: 'User: {{user.name}}
', }) export class UserProfile { private userService = inject(UserClient); // Valid @@ -851,7 +851,7 @@ Angular allows `inject()` in these locations: @Component({ selector: 'app-profile', - template: 'User: {{user().name}}
', + template: 'User: {{user.name}}
', }) export class UserProfile { private userService: UserClient; @@ -963,8 +963,7 @@ setTimeout(() => { This error occurs when two or more services depend on each other, creating a circular dependency that Angular cannot resolve. ``` -NG0200: Circular dependency in DI detected for AuthClient - Dependency path: AuthClient -> UserClient -> AuthClient +NG0200: Circular dependency detected for `AuthClient`. Path: AuthClient -> UserClient -> AuthClient. ``` The dependency path shows the cycle: `AuthClient` depends on `UserClient`, which depends back on `AuthClient`. diff --git a/adev-ja/src/content/guide/di/defining-dependency-providers.md b/adev-ja/src/content/guide/di/defining-dependency-providers.md index 5784af27f3..3d620f02b0 100644 --- a/adev-ja/src/content/guide/di/defining-dependency-providers.md +++ b/adev-ja/src/content/guide/di/defining-dependency-providers.md @@ -39,7 +39,7 @@ NOTE: The string parameter (e.g., `'api.url'`) is a description purely for debug An `InjectionToken` that has a `factory` results in `providedIn: 'root'` by default (but can be overridden via the `providedIn` prop). ```ts {header: "/app/config.token.ts"} -import {InjectionToken} from '@angular/core'; +import {InjectionToken, Component, inject} from '@angular/core'; export interface AppConfig { apiUrl: string; @@ -548,7 +548,7 @@ class ApiClient { } // Factory function that configures based on user tier -import {inject} from '@angular/core'; +import {inject, Component} from '@angular/core'; import {HttpClient} from '@angular/common/http'; const apiClientFactory = () => { const http = inject(HttpClient); @@ -786,6 +786,7 @@ For more complex scenarios, you can combine multiple configuration approaches: ```ts {header: "/libs/http-client/src/provider.ts"} import {Provider, InjectionToken, inject} from '@angular/core'; +import {bootstrapApplication} from '@angular/platform-browser'; // Feature flags for optional functionality export enum HttpFeatures { diff --git a/adev-ja/src/content/guide/di/hierarchical-dependency-injection.en.md b/adev-ja/src/content/guide/di/hierarchical-dependency-injection.en.md index bd6873ea5f..6fe64ebf2a 100644 --- a/adev-ja/src/content/guide/di/hierarchical-dependency-injection.en.md +++ b/adev-ja/src/content/guide/di/hierarchical-dependency-injection.en.md @@ -303,7 +303,7 @@ export class Host { } ``` -Since `Host` has the `host` option , no matter what the parent of `Host` might have as a `flower.emoji` value, the `Host` will use tulip🌷.
+Since `Host` has the `host` option, no matter what the parent of `Host` might have as a `flower.emoji` value, the `Host` will use tulip 🌷.
### Modifiers with constructor injection
@@ -699,10 +699,10 @@ These four bindings demonstrate the difference between `providers` and `viewProv
Remember that the dog emoji 🐶 is declared inside the `<#VIEW>` of `Child` and isn't visible to the projected content.
Instead, the projected content sees the whale 🐳.
-You might wonder why the projected `🐳 from `App`'s `viewProviders`.
+You might wonder why the projected `🐳, which is the root-provided `AnimalService`.
The reason is that Angular DI tracks **where a component was declared**, not where it ends up being rendered.
-`🐶), but `App`'s providers (🐳) are still reachable up the tree.
+`🐶), but the root `AnimalService` (🐳) is still reachable up the tree.
However, in the next output section though, the `Inspector` is an actual child component of `Child`, `Inspector` is inside the `<#VIEW>`, so when it asks for the `AnimalService`, it sees the dog 🐶.
@@ -741,7 +741,7 @@ The `AnimalService` in the logical tree would look like this:
```
The projected `🐳 because 🐶 belongs to `Child`'s view and projected content can't reach it.
-🐳 is accessible because `🐳 is accessible because `🐶 — it's inside the `<#VIEW>`, so no boundary to cross.
@@ -1013,7 +1013,7 @@ Each tax return component has the following characteristics:
- Can change a tax return without affecting a return in another component
- Has the ability to save the changes to its tax return or cancel them
-Suppose that the `HeroTaxReturn` had logic to manage and restore changes.
+Suppose that the `HeroTaxReturnEditor` had logic to manage and restore changes.
That would be a straightforward task for a hero tax return.
In the real world, with a rich tax return data model, the change management would be tricky.
You could delegate that management to a helper service, as this example does.
@@ -1053,10 +1053,10 @@ export class HeroTaxReturnService {
}
```
-Here is the `HeroTaxReturn` that makes use of `HeroTaxReturnService`.
+Here is the `HeroTaxReturnEditor` that makes use of `HeroTaxReturnService`.
```typescript
-import {Component, input, output} from '@angular/core';
+import {Component, effect, inject, input, output} from '@angular/core';
import {HeroTaxReturn} from './hero';
import {HeroTaxReturnService} from './hero-tax-return.service';
@@ -1066,25 +1066,21 @@ import {HeroTaxReturnService} from './hero-tax-return.service';
styleUrls: ['./hero-tax-return.css'],
providers: [HeroTaxReturnService],
})
-export class HeroTaxReturn {
+export class HeroTaxReturnEditor {
message = '';
close = output🐶 は、 `Child` の `<#VIEW>` 内に宣言され、投影されたコンテンツには可視ではないことを覚えておいてください。
代わりに、投影されたコンテンツには、クジラ 🐳 が表示されます。
-なぜ投影された `🐳 を依然として見られるのか疑問に思うかもしれません。
+投影された`🐳を参照できる理由を疑問に思うかもしれません。
その理由は、Angular DIは**コンポーネントが宣言された場所**を追跡し、最終的にレンダリングされる場所は追跡しないためです。
-`🐶) へのアクセスは遮断されますが、`App` のプロバイダー (🐳) はツリーを上に辿って引き続き到達可能です。
+`🐶)にはアクセスできませんが、ツリーの上位にあるルートの`AnimalService`(🐳)にはアクセスできます。
ただし、次の出力セクションでは `Inspector` は `Child` の実際の子コンポーネントです。そして `Inspector` は `<#VIEW>` の内側にあるため、 `AnimalService` を要求すると、犬 🐶 が表示されます。
@@ -741,7 +741,7 @@ Emoji from AnimalService: 🐶
```
投影された `🐳 を取得するのは、犬 🐶 が `Child` のビューに属しており、投影されたコンテンツからは到達できないためです。
-クジラ 🐳 にアクセスできるのは、`🐳にアクセスできるのは、`🐶 を取得します。これは `<#VIEW>` の内側にあるため、超えるべき境界がないからです。
@@ -1013,7 +1013,7 @@ export class VillainsList {}
- 別のコンポーネントの申告に影響を与えずに税務申告を変更できます
- 税務申告の変更を保存するか、キャンセルする機能があります
-`HeroTaxReturn` に、変更を管理および復元するためのロジックがあるとします。
+`HeroTaxReturnEditor`に、変更を管理および復元するロジックがあるとします。
これは、ヒーローの税務申告にとっては簡単なタスクです。
現実世界では、豊富な税務申告データモデルでは、変更管理が複雑になります。
この例のように、この管理をヘルパーサービスに委任できます。
@@ -1053,10 +1053,10 @@ export class HeroTaxReturnService {
}
```
-以下は、 `HeroTaxReturnService` を使用する `HeroTaxReturn` です。
+以下は、`HeroTaxReturnService`を使用する`HeroTaxReturnEditor`です。
```typescript
-import {Component, input, output} from '@angular/core';
+import {Component, effect, inject, input, output} from '@angular/core';
import {HeroTaxReturn} from './hero';
import {HeroTaxReturnService} from './hero-tax-return.service';
@@ -1066,25 +1066,21 @@ import {HeroTaxReturnService} from './hero-tax-return.service';
styleUrls: ['./hero-tax-return.css'],
providers: [HeroTaxReturnService],
})
-export class HeroTaxReturn {
+export class HeroTaxReturnEditor {
message = '';
close = output