метод

ю, что в stackoverflow уже выложено много одних и тех же вопросов, и я пробовал разные решения, чтобы избежать ошибки времени выполнения, но ни один из них не работает для меня.

Компонент и 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">
     //some other html here
</div>

Обратите внимание: этот компонент загружается динамически с использованием DynamicComponentLoader

После устранения неполадок я определил пару проблем

Прежде всего этот дочерний компонент загружается динамически с помощью DynamicComponentResolver и передачей входных значений, как показано ниже

 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;

  }

Даже если я изменил html дочернего компонента, как показано ниже, я получаю ту же ошибку. Просто добавьте угловой атрибут ngclass

<div class="container-fluid ds-iconwidget-wrapper text-center" [ngClass]="Sample">

</div>

Моя база данных и все работает нормально. Нужно ли что-то делать с родительским компонентом? Я уже перепробовал все события жизненного цикла в дочернем компоненте

Ответы на вопрос(0)

Ваш ответ на вопрос