DevExtreme Angular - Zoneless Change Detection
DevExtreme Angular components support zoneless change detection (the default mode in new applications starting with Angular 21). No additional configuration is required. Zone-based applications continue to work as before.
In zoneless applications, Angular updates the view only after a change notification. DevExtreme components send these notifications when they raise events or change their properties. Asynchronous code and callback functions do not notify Angular when they change class fields. In asynchronous code and callback functions, store data in signals or call markForCheck(). The same applies to OnPush components in zone-based applications.
The Angular guide on zoneless change detection describes how to migrate an existing application.
Automatic View Updates
Angular updates the view without additional code when you use the following patterns:
- Event bindings in templates, such as
(onSelectionChanged) - Two-way bindings to signals or class fields, including bindings in nested components (such as
[(pageIndex)]indxo-data-grid-paging) - Output subscriptions in code, such as
onSelectionChanged.subscribe() - Event handlers attached using the on(eventName, eventHandler) method, including optionChanged handlers for properties that support two-way binding
- Template expressions that read component properties, such as
grid.selectedRowKeys - A formData object that users edit in the Form
- Custom template content that reads signals or contains event bindings
Asynchronous Code
In zoneless applications, Angular does not update the view when asynchronous code assigns values to class fields (for example, in timers, promises, fetch requests, or third-party library callbacks). Store these values in signals:
- <dx-list [dataSource]="tasks()"></dx-list>
- import { Component, signal } from '@angular/core';
- import { DxListModule } from 'devextreme-angular/ui/list';
- @Component({
- // ...
- standalone: true,
- imports: [DxListModule]
- })
- export class AppComponent {
- tasks = signal<string[]>([]);
- constructor() {
- fetch('https://example.com/api/tasks')
- .then((response) => response.json())
- .then((tasks: string[]) => this.tasks.set(tasks));
- }
- }
If asynchronous code modifies a bound array, the component does not receive the change. Pass a new array to the signal's set() or update() method instead.
You can also call markForCheck() after the change.
Callback Functions
Functions that you pass as property values are called outside Angular event bindings. Examples include the following:
- Event handlers in nested components, such as
[onClick]indxi-data-grid-button - Functions in objects, such as onItemClick in Chat suggestions or onClick in Toolbar item options
In zoneless applications, Angular does not update the view when one of these functions assigns a value to a class field. Store data in a signal:
- <dx-data-grid [dataSource]="employees">
- <dxi-data-grid-column dataField="fullName"></dxi-data-grid-column>
- <dxi-data-grid-column type="buttons">
- <dxi-data-grid-button
- icon="info"
- [onClick]="showDetails">
- </dxi-data-grid-button>
- </dxi-data-grid-column>
- </dx-data-grid>
- <p>{{ selectedName() }}</p>
- import { Component, signal } from '@angular/core';
- import { DxDataGridModule, type DxDataGridTypes } from 'devextreme-angular/ui/data-grid';
- @Component({
- // ...
- standalone: true,
- imports: [DxDataGridModule]
- })
- export class AppComponent {
- employees = [{ fullName: 'John Heart' }, { fullName: 'Samantha Bright' }];
- selectedName = signal('');
- showDetails = (e: DxDataGridTypes.ColumnButtonClickEvent) => {
- this.selectedName.set(e.row?.data.fullName);
- };
- }
Declare these callbacks as arrow functions so that this refers to your Angular component. You can also call markForCheck() in these callbacks instead of storing data in a signal.
Recommended Patterns
Use the following patterns in zoneless applications:
| Scenario | Recommendation |
|---|---|
| Display data that a component changes | Use two-way binding to a signal, for example, [(value)]="value". |
| Respond to component events | Use event bindings in templates or subscribe to outputs in code. |
| Change data in asynchronous code or callback functions | Store the data in signals or call markForCheck(). |
| Update a bound array in asynchronous code | Pass a new array to the signal's set() or update() method. |
| Refresh the view manually | Call markForCheck(). Do not call ApplicationRef.tick() or detectChanges() in frequently called handlers. |