Skip to content
This repository has been archived by the owner on Sep 26, 2020. It is now read-only.

ExpressionChangedAfterItHasBeenCheckedError #52

Open
BickelLukas opened this issue Feb 28, 2020 · 3 comments
Open

ExpressionChangedAfterItHasBeenCheckedError #52

BickelLukas opened this issue Feb 28, 2020 · 3 comments

Comments

@BickelLukas
Copy link

Using angular 9 I get an ExpressionChangedAfterItHasBeenCheckedError.

I solved it by overriding the MatCarouselSlideComponent and adding { static: true } to the templateRef property.

This is my component:

import { Component, forwardRef, TemplateRef, ViewChild } from '@angular/core';
import { MatCarouselSlideComponent } from '@ngmodule/material-carousel';

@Component({
    selector: 'agp-carousel-slide',
    templateUrl: './carousel-slide.component.html',
    styleUrls: ['./carousel-slide.component.scss'],
    providers: [
        { provide: MatCarouselSlideComponent, useExisting: forwardRef(() => CarouselSlideComponent) }
    ]
})
export class CarouselSlideComponent extends MatCarouselSlideComponent {
    @ViewChild(TemplateRef, { static: true }) public templateRef: TemplateRef<any>;
}

It would be nice if this fix gets included in the core library so we dont have to override the component ourselves.

@anilkumar007
Copy link

@BickelLukas The above solution is not working. it is throwing an error as type static boolean is not assignable to read value { static: true }

@BickelLukas
Copy link
Author

@anilkumar007 The static property has been added to ViewChild in Angular 8. If you have a previous version this fix will not work

@bunda3d
Copy link

bunda3d commented May 23, 2020

I'm using Angular 9 and can't get this fix to work. If I just add the static statement to viewchild it doesn't work; if I extend the class, import from the package and add the static statement it errors about the DomSanitizer constructor. Any more guidance or fixes for the ExpressionChangedAfterItHasBeenCheckedError ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants