ChangeDetectorRef.detectChanges() working for the first time when given in ngAfterViewChecked

397 Views Asked by At

I am working on a Angular 4 application that uses smartadmin template. I have a popup inside ng-formly.
That popup is rendering a form using repeated section. On popup button click an error is beeing thrown:

'ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'true'. Current value: 'false'.'

For resolving this I gave detectChanges() method of ChangeDetectorRef in ngAfterViewChecked.
Now, if I click the popup button for the first time, the form is rendering in the popup.
For further button clicks I am getting:

'TypeError: this.formControl.push is not a function' from repeatedSection. repeatedSection is initialising twice from the second time onwards.

Please help me out fixing this issue.

0

There are 0 best solutions below