1

The demo to create a dynamic component shows an error in the console in dev mode

https://angular.io/guide/dynamic-component-loader

https://angular.io/generated/live-examples/dynamic-component-loader/eplnkr.html

I've fixed it by adding a setTimeout to the ngAfterViewInit -> loadComponent call.

I'd like to know the correct way to handle a simple example like this without generating the error, and without using setTimeout

Steven M
  • 574
  • 3
  • 18
  • check [this](https://stackoverflow.com/a/44691880/2545680) and [this](https://stackoverflow.com/a/44691144/2545680) answers – Max Koretskyi Jun 23 '17 at 05:19
  • also [Everything you need to know about the `ExpressionChangedAfterItHasBeenCheckedError` error](https://medium.com/@maximus.koretskyi/everything-you-need-to-know-about-the-expressionchangedafterithasbeencheckederror-error-e3fd9ce7dbb4) explains this behavior in great details – Max Koretskyi Jul 02 '17 at 05:25

0 Answers0