I know that many of the same questions have already been posted in the stack overflow, and I tried different solutions to avoid a runtime error, but none of them work for me.

Component and HTML
export class TestComponent implements OnInit, AfterContentChecked { @Input() DataContext: any; @Input() Position: any; sampleViewModel: ISampleViewModel = { DataContext: : null, Position: null }; constructor(private validationService: IValidationService, private modalService: NgbModal, private cdRef: ChangeDetectorRef) { } ngOnInit() { } ngAfterContentChecked() { debugger; this.sampleViewModel.DataContext = this.DataContext; this.sampleViewModel.Position = this.Position; } <div class="container-fluid sample-wrapper text-center" [ngClass]="sampleViewModel.DataContext?.Style?.CustomCssClass +' samplewidget-'+ sampleViewModel.Position?.Columns + 'x' + sampleViewModel.Position?.Rows">
Please note: this component is loaded dynamically using DynamicComponentLoader
After troubleshooting, I found a couple of problems
First of all, this child component is loaded dynamically using DynamicComponentResolver and passing input values ββas shown below
ngAfterViewInit() { this.renderWidgetInsideWidgetContainer(); } renderWidgetInsideWidgetContainer() { let component = this.storeFactory.getWidgetComponent(this.dataSource.ComponentName); let componentFactory = this._componentFactoryResolver.resolveComponentFactory(component); let viewContainerRef = this.widgetHost.viewContainerRef; viewContainerRef.clear(); let componentRef = viewContainerRef.createComponent(componentFactory); debugger; (<IDataBind>componentRef.instance).WidgetDataContext = this.dataSource.DataContext; (<IDataBind>componentRef.instance).WidgetPosition = this.dataSource.Position; }
Even if I change the html of my child component as shown below, I get the same error. Just add the angular ngclass attribute
<div class="container-fluid ds-iconwidget-wrapper text-center" [ngClass]="Sample"> </div>
My database and everything is working fine. Do I need to do something with the parent component? I already tried all life cycle events in the child component
source share