Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error using reverse (ExpressionChangedAfterItHasBeenCheckedError) #47

Closed
erperejildo opened this issue Feb 10, 2018 · 6 comments
Closed

Comments

@erperejildo
Copy link

erperejildo commented Feb 10, 2018

<ion-card *ngFor="let team of gameProvider.game.teams | orderBy: 'team.points':true; let i = index">

ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'Team 2'. Current value: 'Team 1'.

These values are in team.title. The content inside the html is empty, I'm not displaying anything yet

@VadimDez
Copy link
Owner

Could you show how gameProvider.game.teams looks like?

@erperejildo
Copy link
Author

screen shot 2018-02-11 at 18 06 46

@VadimDez
Copy link
Owner

First of all doing orderBy: 'team.points' won't work anyways, try:

<div *ngFor="let team of gameProvider.game.teams | orderBy: 'points': true">
  {{ team | json }}
</div>

@erperejildo
Copy link
Author

I also tried that but same error.

Using Angular 5 with Ionic 3 if that matters

@erperejildo
Copy link
Author

erperejildo commented Feb 25, 2018

@VadimDez any update on this?

This might help: https://blog.angularindepth.com/everything-you-need-to-know-about-the-expressionchangedafterithasbeencheckederror-error-e3fd9ce7dbb4

I also tried it out with a different model and it works (?)

@erperejildo erperejildo changed the title Error using reverse Error using reverse (ExpressionChangedAfterItHasBeenCheckedError) Feb 25, 2018
@erperejildo
Copy link
Author

Solved using this way:

import { ChangeDetectorRef } from '@angular/core';

constructor(private cdRef:ChangeDetectorRef) {
  }

ngAfterViewInit() {
    this.teams = this.gameProvider.game.teams;
    this.cdRef.detectChanges();
  }

<ion-card *ngFor="let team of teams | orderBy: 'points':true; let i = index">

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

No branches or pull requests

2 participants