Angular course ยท Module 14: Advanced Patterns
The Future of Angular
In this lesson6
Angular keeps evolving - like a samurai perfecting his skills throughout his entire life.
Zoneless Angular (Angular 18+)
// app.config.ts
import { provideExperimentalZonelessChangeDetection } from '@angular/core';
export const appConfig: ApplicationConfig = {
providers: [
provideExperimentalZonelessChangeDetection()
]
};
// Components must use Signals or manual markForCheck
@Component({
selector: 'app-counter',
template: `
<p>Count: {{ count() }}</p>
<button (click)="increment()">+1</button>
`
})
export class CounterComponent {
count = signal(0);
increment(): void {
this.count.update(c => c + 1);
}
}This is the Angular 19 version, where the function still has Experimental in its name. Angular 20 renamed it to provideZonelessChangeDetection() (stable since 20.2), and since Angular 21 zoneless is the default. So check the version in package.json: in Angular 19 you write provideExperimentalZonelessChangeDetection(), in newer versions provideZonelessChangeDetection().
Signals - Full Integration
// Angular 19+ features
import { signal, computed, effect, linkedSignal, resource } from '@angular/core';
@Component({...})
export class FutureComponent {
// linkedSignal - resets when source changes
userId = input.required<number>();
selectedTab = linkedSignal({ source: this.userId, computation: () => 'profile' }); // Resets on userId change
// resource() - declarative data fetching
userResource = resource({
request: () => this.userId(),
loader: async ({ request: id }) => {
const response = await fetch(`/api/users/${id}`);
return response.json();
}
});
// The previous value comes from linkedSignal (computed() does not get it)
count = signal(0);
changes = linkedSignal<number, { current: number; previous: number }>({
source: this.count,
computation: (current, prev) => ({ current, previous: prev?.value.current ?? 0 })
});
}Partial Hydration (Experimental)
// Selective hydration - only interactive parts
@Component({
template: `
<!-- Static content - no JS needed -->
<header>{{ title }}</header>
<!-- Hydration on interaction -->
@defer (hydrate on interaction) {
<app-interactive-widget />
}
<!-- Hydration when visible -->
@defer (hydrate on viewport) {
<app-comments />
}
`
})
export class HybridComponent {}esbuild and Vite (Angular 17+)
Since Angular 17, new projects use the application builder: esbuild bundles the production build, and Vite only acts as the development server in ng serve. Since Angular 18 this builder also ships in a separate @angular/build package, as in this example:
// angular.json - application builder: esbuild bundles the app, Vite only serves it in ng serve
{
"architect": {
"build": {
"builder": "@angular/build:application"
}
}
}Best Practices in Angular 19
- Standalone Components - default, NgModules optional
- Signals - preferred over RxJS for component state
- Functional Guards/Resolvers - instead of classes
- Control Flow - @if, @for, @switch instead of directives
- inject() - instead of constructor injection
- TypeScript Strict - full type control
- ESLint - instead of TSLint
- Zoneless - for maximum performance
Journey Summary
Congratulations, Angular master!
You have learned:
- TypeScript and Standalone Components
- Signals and reactivity
- RxJS and reactive programming
- Reactive forms
- Routing and Guards
- Services and Dependency Injection
- State Management
- HttpClient and API
- Testing
- Security and performance
- Styling and animations
- Advanced patterns
Ganbatte! (Good luck!)
The path of a samurai never ends - Angular keeps evolving, so keep learning!
Spotted a mistake in this lesson?
Check yourself
Answer the questions from this lesson. Pick an answer to see right away whether it is correct.
1. What is required for an Angular application to run in zoneless mode?
2. Which of the following is NOT recommended in Angular 2024+?
These are 2 of 5 questions for this lesson. Solve the rest in the game.
Hands-on tasks in the game
- Code editor
Complete the Angular application configuration in zoneless mode.
- Horizontal ordering
Arrange the partial hydration expression that triggers on interaction (one line, left to right):
- Click in order
Click the elements in order to build the call that enables zoneless mode: provideExperimentalZonelessChangeDetection()
- Click in order
Click the elements in order to build the opening of a conditional block: @if (isVisible()) {
- Vertical ordering
Order the recommended approaches from the oldest (legacy) to the newest (recommended):
- Click in order
Click the elements in order to build the call for a signal that resets when its source changes: linkedSignal(...)
Tasks after this lesson
- QuestionZoneless Angular
- QuestionBest Practices
- QuestionDeclarative data fetching
- Coding taskPractice: Zoneless Config
- Put in orderHydration on interaction
- QuestionBundler in Angular
- Click in orderZoneless configuration
- Click in orderModern control flow
- Put in orderEvolution of the Angular approach
- Click in orderSignal that resets when its source changes
- QuestionPurpose of zoneless mode
- VideoModule Summary