Jeremy Thomas
Jeremy Thomas

Reputation: 6684

Ionic / Angular: Avoiding the ExpressionChangedAfterItHasBeenCheckedError

I have a form and I would like to display different content depending on if a client's email is available. I have a simple input with the following markup:

<ion-input *ngIf="client.email" readonly="true" [(ngModel)]="client.email" type="text" name="email"></ion-input>

But this causes an error:

Uncaught Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: ''. Current value: 'email_goes_here'.

What is the workaround to avoid this? I load client in my component's ionViewWillEnter lifecycle hook.

Upvotes: 0

Views: 828

Answers (1)

Rahul Singh
Rahul Singh

Reputation: 19622

The work around to this problem is to put everything inside a setTimeout method.

This question might help

Upvotes: 1

Related Questions