Skip to content

*ngFor loop causes 'changed after it was checked' error #9

Description

@blubberbo

I have the following code:

<li *ngFor="let thing of things">
        <a [href]="utilitiesService.convertEndpointToAnchorLink(thing.name)" contentsLink pageScroll>{{
          thing.name
        }}</a>
      </li>

but it gives me the Expression has changed after it was checked error - I have narrowed down the cause being the contentsLink attribute. Implementing the following in my component took the error away, but I was wondering if there is a more proper way this could be handled?

constructor(private cd: ChangeDetectorRef) {}

 ngAfterViewInit() {
    this.cd.detectChanges();
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions