Loading...
Loading...
ALWAYS use when working with Angular Zoneless, zoneless change detection, provideZonelessChangeDetection, or removing zone.js in Angular applications.
npx skill4agent add oguzhan18/angular-ecosystem-skills angular-zonelessexport const appConfig: ApplicationConfig = {
providers: [
provideZonelessChangeDetection()
]
};@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<p>Count: {{ count() }}</p>
<p>Double: {{ double() }}</p>
`
})
export class CounterComponent {
count = signal(0);
double = computed(() => this.count() * 2);
increment() {
this.count.update(c => c + 1);
}
}constructor() {
afterNextRender(() => {
// Runs after rendering, outside zone
this.initChart();
});
}constructor() {
afterRender(() => {
// Runs after every render
});
}@Component({
template: `
@if (data$ | async; as data) {
{{ data.name }}
}
`
})
export class AsyncComponent {
data$ = from(fetch('/api/data')).pipe(
share()
);
}constructor(private cdr: ChangeDetectorRef) {}
update() {
this.value = newValue;
this.cdr.markForCheck();
}// polyfills.ts
// Remove or comment out zone.js import
// import 'zone.js';import { untracked } from '@angular/core';
ngOnInit() {
// Read without creating dependency
const value = untracked(() => this.signal());
}@HostListener('click')
onClick() {
// Works without zone.js
this.count.update(c => c + 1);
}TestBed.configureTestingModule({
providers: [
provideZonelessChangeDetection()
]
});