i am using angular material stepper and the functionality is working as expected and getting below error:
2
votes
2 Answers
0
votes
0
votes
A different approach to avoid the ExpressionChangedAfterItHasBeenCheckedError in general is to use the ChangeDetectionStrategy.OnPush in your components:
@Component({
selector: 'my-component',
templateUrl: '/path/to/my-component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class MyComponent {}
Components using the Push ChangeDetectionStrategy only rerender the DOM if the data displayed has changed instead of rerendering on every Angular change detection cycle. Therefore, this spares a lot of ressources on the client side.
You might want to consider the "downside" that object references passed via @Input() would not trigger this component's change detection and thus the need to eventually trigger it manually with a ChangeDetectorRef, but at the end this approach will lead to cleaner component property/data stream management.
