com um clique
angular-knowledge-patch
Angular v19-v21 features: linkedSignal, resource/httpResource, signal forms, route-level SSR render modes, incremental hydration, zoneless change detection, Vitest migration, and Angular Aria components.
Menu
Angular v19-v21 features: linkedSignal, resource/httpResource, signal forms, route-level SSR render modes, incremental hydration, zoneless change detection, Vitest migration, and Angular Aria components.
| name | angular-knowledge-patch |
| description | Angular v19-v21 features: linkedSignal, resource/httpResource, signal forms, route-level SSR render modes, incremental hydration, zoneless change detection, Vitest migration, and Angular Aria components. |
| category | knowledge-patch |
| version | 21.0.0 |
| license | MIT |
| metadata | {"author":"Nevaberry","tags":["angular","signals","ssr","forms","zoneless"]} |
Baseline: Angular through v18.x (signals basics, new control flow, standalone components, zoneless experimental, SSR hydration basics, esbuild builder).
This patch covers features from Angular v19 through v21 (2024-11 to 2025-11).
| Topic | File | Key APIs |
|---|---|---|
| Signals & Reactivity | references/signals-and-reactivity.md | linkedSignal, resource, httpResource |
| Signal Forms | references/signal-forms.md | form(), FormField, validators |
| SSR & Hydration | references/ssr-and-hydration.md | RenderMode, ServerRoute, incremental hydration |
| Zoneless & Testing | references/zoneless-and-testing.md | provideZonelessChangeDetection, Vitest |
| Components & Templates | references/components-and-templates.md | Angular Aria, regex in templates, @defer viewport |
| API | Status | Import | Purpose |
|---|---|---|---|
linkedSignal | Stable (v20) | @angular/core | Writable signal that resets when source changes |
resource | Experimental | @angular/core | Signal-based async data loading |
httpResource | Experimental | @angular/common/http | Signal-based HTTP fetching (reads only) |
form() | Experimental (v21+) | @angular/forms/signals | Signal-based forms with schema validation |
const selected = linkedSignal(() => options()[0]);
selected.set(options()[2]); // writable
// Resets to options()[0] when options() changes
import { resource, Signal } from '@angular/core';
const userId: Signal<string> = getUserId();
const userResource = resource({
params: () => ({ id: userId() }),
loader: ({ params, abortSignal }) =>
fetch(`/users/${params.id}`, { signal: abortSignal }),
});
// userResource.value(), .isLoading(), .error(), .hasValue()
// IMPORTANT: .value() throws in error state — guard with .hasValue()
import { httpResource } from '@angular/common/http';
// Reactive URL — re-fetches when userId() changes
const user = httpResource<User>(() => `/api/user/${userId()}`);
// user.value(), .isLoading(), .error(), .hasValue(), .headers()
// Only for reads — use HttpClient directly for mutations
bootstrapApplication(AppComponent, {
providers: [
provideZonelessChangeDetection(),
provideBrowserGlobalErrorListeners(),
],
});
// Remove zone.js polyfill from angular.json
# Migrate existing Jasmine tests
ng g @schematics/angular:refactor-jasmine-vitest
import { RenderMode, ServerRoute } from '@angular/ssr';
export const serverRouteConfig: ServerRoute[] = [
{ path: '/login', mode: RenderMode.Server },
{ path: '/dashboard', mode: RenderMode.Client },
{
path: '/product/:id',
mode: RenderMode.Prerender,
async getPrerenderPaths() {
return (await inject(ProductService).getIds()).map((id) => ({ id }));
},
},
{ path: '/**', mode: RenderMode.Prerender },
];
provideClientHydration(withIncrementalHydration())
// Template
@defer (hydrate on viewport) {
<shopping-cart/>
}
import { form, FormField, required, email, submit } from '@angular/forms/signals';
loginModel = signal({ email: '', password: '' });
loginForm = form(this.loginModel, (schema) => {
required(schema.email, { message: 'Email is required' });
email(schema.email, { message: 'Invalid email' });
required(schema.password, { message: 'Password is required' });
});
Template: <input [formField]="loginForm.email" />, access state via loginForm.email() → .value(), .touched(), .valid(), .errors(), .dirty(), .pending().
const selected = linkedSignal<ShippingMethod[], ShippingMethod>({
source: shippingOptions,
computation: (newOptions, previous) =>
newOptions.find(o => o.id === previous?.value.id) ?? newOptions[0],
});
const user = httpResource(() => ({
url: `/api/user/${userId()}`,
method: 'GET',
headers: { 'X-Special': 'true' },
params: { fast: 'yes' },
}));
// Response type variants
httpResource.text(() => url);
httpResource.blob(() => url);
// Zod validation
const res = httpResource(() => `/api/people/${id()}`, {
parse: starWarsPersonSchema.parse,
});
Headless accessible components: npm i @angular/aria. Patterns: Accordion, Combobox, Grid, Listbox, Menu, Tabs, Toolbar, Tree. Unstyled — you provide all CSS.
Implement web accessibility (a11y) best practices following WCAG guidelines to create inclusive, accessible user interfaces.
Android development guidelines for Kotlin with clean architecture, MVI pattern, Material Design, and best practices for building robust mobile applications
Expert guidance for Angular and TypeScript development focused on scalable, high-performance web applications
Expert in Angular TypeScript development with scalable, high-performance patterns
Master REST and GraphQL API design principles to build intuitive, scalable, and maintainable APIs that delight developers. Use when designing new APIs, reviewing API specifications, or establishing API design standards.
Guidelines for ASP.NET Core web development covering API design, authentication, caching, and best practices