Mat Dialog Error in Angular Component ExpressionChangedAfterItHasBeenCheckedError

It's hard to tell what's causing the problem without knowing a lot of details about all the invoked functions. However, ExpressionChangedAfterItHasBeenCheckedError can most likely be fixed by doing the following:

  • try moving the code into ngAfterViewInit lifecycle hook,
  • try wrapping the code inside the setTimeout.

Finally, read Everything you need to know about the ExpressionChangedAfterItHasBeenCheckedError error. It should give you a better idea about the error you are facing.