Skip to content

Commit 341fadd

Browse files
GabeSilvaDevkirjs
authored andcommitted
docs: fix inaccurate statements and broken examples across adev
Fix code examples that don't compile or fail at runtime, wrong API names, and statements of defaults or behavior that no longer match the source, across the forms, signals, http, routing, DI, components, testing, CLI, reference, ecosystem and tutorial pages.
1 parent efaf431 commit 341fadd

57 files changed

Lines changed: 159 additions & 172 deletions

Some content is hidden

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

‎adev/src/content/best-practices/runtime-performance/skipping-subtrees.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Change detection is sufficiently fast for most applications. However, when an ap
88

99
OnPush is the default change detection strategy in Angular (since v22). It instructs Angular to run change detection for a component subtree **only** when:
1010

11-
- The root component of the subtree receives new inputs as the result of a template binding. Angular compares the current and past value of the input with `==`.
11+
- The root component of the subtree receives new inputs as the result of a template binding. Angular compares the current and past value of the input with `Object.is`.
1212
- Angular handles an event _(for example using event binding, output binding, or `@HostListener` )_ in the subtree's root component or any of its children whether they are using OnPush change detection or not.
1313

1414
## Common change detection scenarios

‎adev/src/content/ecosystem/rxjs-interop/output-interop.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
TIP: This guide assumes you're familiar with [component and directive outputs](guide/components/outputs).
44

5-
The `@angular/rxjs-interop` package offers two APIs related to component and directive outputs.
5+
The `@angular/core/rxjs-interop` package offers two APIs related to component and directive outputs.
66

77
## Creating an output based on an RxJs Observable
88

‎adev/src/content/ecosystem/rxjs-interop/signals-interop.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ Here, only the last value (3) will be logged.
128128

129129
## Using `rxResource` for async data
130130

131-
Angular's [`resource` function](/guide/signals/resource) gives you a way to incorporate async data into your application's signal-based code. Building on top of this pattern, `rxResource` lets you define a resource where the source of your data is defined in terms of an RxJS `Observable`. Instead of accepting a `loader` function, `rxResource` accepts a `stream` function that accepts an RxJS `Observable`.
131+
Angular's [`resource` function](/guide/signals/resource) gives you a way to incorporate async data into your application's signal-based code. Building on top of this pattern, `rxResource` lets you define a resource where the source of your data is defined in terms of an RxJS `Observable`. Instead of accepting a `loader` function, `rxResource` accepts a `stream` function that returns an RxJS `Observable`.
132132

133133
```typescript
134134
import {Component, inject} from '@angular/core';

‎adev/src/content/ecosystem/service-workers/communications.md‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@ The `SwUpdate` service supports three separate operations:
1414

1515
### Version updates
1616

17-
The `versionUpdates` is an `Observable` property of `SwUpdate` and emits five event types:
18-
19-
| Event types | Details |
20-
| :------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
21-
| `VersionDetectedEvent` | Emitted when the service worker has detected a new version of the app on the server and is about to start downloading it. |
22-
| `NoNewVersionDetectedEvent` | Emitted when the service worker has checked the version of the app on the server and did not find a new version. |
23-
| `VersionReadyEvent` | Emitted when a new version of the app is available to be activated by clients. It may be used to notify the user of an available update or prompt them to refresh the page. |
24-
| `VersionInstallationFailedEvent` | Emitted when the installation of a new version failed. It may be used for logging/monitoring purposes. |
25-
| `VersionFailedEvent` | Emitted when a version encounters a critical failure (such as broken hash errors) that affects all clients using that version. Provides error details for debugging and transparency. |
17+
The `versionUpdates` is an `Observable` property of `SwUpdate` and emits four event types:
18+
19+
| Event types | Details |
20+
| :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
21+
| `VersionDetectedEvent` | Emitted when the service worker has detected a new version of the app on the server and is about to start downloading it. |
22+
| `NoNewVersionDetectedEvent` | Emitted when the service worker has checked the version of the app on the server and did not find a new version. |
23+
| `VersionReadyEvent` | Emitted when a new version of the app is available to be activated by clients. It may be used to notify the user of an available update or prompt them to refresh the page. |
24+
| `VersionInstallationFailedEvent` | Emitted when the installation of a new version failed. It may be used for logging/monitoring purposes. |
2625

2726
<docs-code header="log-update.service.ts" path="adev/src/content/examples/service-worker-getting-started/src/app/log-update.service.ts" region="sw-update"/>
2827

‎adev/src/content/ecosystem/service-workers/config.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ The ServiceWorker redirects navigation requests that don't match any `asset` or
332332
A request is considered to be a navigation request if:
333333

334334
- Its [method](https://developer.mozilla.org/docs/Web/API/Request/method) is `GET`
335-
- Its [mode](https://developer.mozilla.org/docs/Web/API/Request/mode) is `navigation`
335+
- Its [mode](https://developer.mozilla.org/docs/Web/API/Request/mode) is `navigate`
336336
- It accepts a `text/html` response as determined by the value of the `Accept` header
337337
- Its URL matches the following criteria:
338338
- The URL must not contain a file extension (that is, a `.`) in the last path segment

‎adev/src/content/examples/accessibility/src/app/progress-bar.component.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {Component, input} from '@angular/core';
1818
'aria-valuemax': '100',
1919

2020
// Binding that updates the current value of the progressbar.
21-
'[attr.aria-valuenow]': 'value',
21+
'[attr.aria-valuenow]': 'value()',
2222
},
2323
})
2424
export class ExampleProgressbarComponent {

‎adev/src/content/examples/service-worker-getting-started/src/app/log-update.service.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ export class LogUpdateService {
1818
case 'VERSION_INSTALLATION_FAILED':
1919
console.log(`Failed to install app version '${evt.version.hash}': ${evt.error}`);
2020
break;
21-
case 'VERSION_FAILED':
22-
console.log(`Version '${evt.version.hash}' failed with error: ${evt.error}`);
23-
break;
2421
}
2522
});
2623
}

‎adev/src/content/guide/components/advanced-configuration.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ import {Component, CUSTOM_ELEMENTS_SCHEMA} from '@angular/core';
4545
export class ComponentWithCustomElements { }
4646
```
4747

48-
Angular does not support any other schemas at this time.
48+
Angular also provides `NO_ERRORS_SCHEMA`, which allows any element and any property.

‎adev/src/content/guide/components/queries.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export class UserProfile {}
102102

103103
If the query does not find a result, its value is `undefined`. This may occur if the target element is absent or hidden by `@if`. Angular keeps the result of `contentChild` up to date as your application state changes.
104104

105-
By default, content queries find only _direct_ children of the component and do not traverse into descendants.
105+
By default, `contentChild` queries traverse into descendants, while `contentChildren` queries find only _direct_ children. See [Content descendants](#content-descendants).
106106

107107
You can also query for multiple results with the `contentChildren` function.
108108

‎adev/src/content/guide/di/debugging-and-troubleshooting-di.md‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ Each component gets its own `UserClient` instance. Changes in one component don'
135135
**Solution:** Use `@Service` for singletons.
136136

137137
```ts {prefer, header: 'Root-level singleton'}
138-
import {Injectable} from '@angular/core';
138+
import {Service} from '@angular/core';
139139

140140
@Service()
141141
export class UserClient {
@@ -250,7 +250,7 @@ export class UserProfile {
250250
Use `runInInjectionContext()` when you need to enable **other code** to call `inject()`. This is useful when accepting callbacks that might use dependency injection:
251251

252252
```angular-ts
253-
import {Component, inject, Injector, input} from '@angular/core';
253+
import {Component, inject, Injector, input, runInInjectionContext} from '@angular/core';
254254
255255
@Component({
256256
selector: 'app-data-loader',
@@ -264,13 +264,13 @@ export class DataLoader {
264264
const callback = this.onLoad();
265265
if (callback) {
266266
// Enable the callback to use inject()
267-
this.injector.runInInjectionContext(callback);
267+
runInInjectionContext(this.injector, callback);
268268
}
269269
}
270270
}
271271
```
272272

273-
The `runInInjectionContext()` method creates a temporary injection context, allowing code inside the callback to call `inject()`.
273+
The `runInInjectionContext()` function creates a temporary injection context, allowing code inside the callback to call `inject()`.
274274

275275
IMPORTANT: Always capture dependencies at the class level when possible. Use `injector.get()` for simple deferred retrieval, and `runInInjectionContext()` only when external code needs to call `inject()`.
276276

@@ -671,7 +671,7 @@ This section provides detailed information about specific Angular DI error codes
671671

672672
### NullInjectorError: No provider for [Service]
673673

674-
**Error code:** None (displayed as `NullInjectorError`)
674+
**Error code:** [NG0201](errors/NG0201)
675675

676676
This error occurs when Angular cannot find a provider for a token in the injector hierarchy. The error message includes a dependency path showing where the injection was attempted.
677677

@@ -855,12 +855,12 @@ Angular allows `inject()` in these locations:
855855
})
856856
export class UserProfile {
857857
private userService: UserClient;
858+
user: ReturnType<UserClient['getUser']>;
858859
859860
constructor() {
860861
this.userService = inject(UserClient); // Valid
862+
this.user = this.userService.getUser();
861863
}
862-
863-
user = this.userService.getUser();
864864
}
865865
```
866866

@@ -882,7 +882,7 @@ Angular allows `inject()` in these locations:
882882
4. **Inside runInInjectionContext()**
883883

884884
```angular-ts
885-
import {Component, inject, Injector} from '@angular/core';
885+
import {Component, inject, Injector, runInInjectionContext} from '@angular/core';
886886
import {UserClient} from './user-client';
887887
888888
@Component({
@@ -893,7 +893,7 @@ Angular allows `inject()` in these locations:
893893
private injector = inject(Injector);
894894
895895
loadUser() {
896-
this.injector.runInInjectionContext(() => {
896+
runInInjectionContext(this.injector, () => {
897897
const userService = inject(UserClient); // Valid
898898
console.log(userService.getUser());
899899
});
@@ -934,7 +934,7 @@ private userService = inject(UserClient) // Capture at class level
934934
private injector = inject(Injector)
935935

936936
someCallback() {
937-
this.injector.runInInjectionContext(() => {
937+
runInInjectionContext(this.injector, () => {
938938
const service = inject(MyClient)
939939
})
940940
}

0 commit comments

Comments
 (0)