ExpressionChangedAfterItHasBeenCheckedError:表达式在检查后已更改。上一个值:'undefined'
我知道在堆栈溢出中已经发布了很多相同的问题,并尝试了不同的解决方案来避免运行时错误,但是没有一个对我有用。 组件和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 …