0

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.

Roham Rafii
  • 2,929
  • 7
  • 35
  • 49
Jeremy Thomas
  • 6,240
  • 9
  • 47
  • 92
  • dupe? https://stackoverflow.com/questions/34364880/expression-has-changed-after-it-was-checked – AT82 Oct 24 '17 at 14:24
  • see this article to understand the error [Everything you need to know about the `ExpressionChangedAfterItHasBeenCheckedError` error](https://blog.angularindepth.com/everything-you-need-to-know-about-the-expressionchangedafterithasbeencheckederror-error-e3fd9ce7dbb4) – Max Koretskyi Oct 24 '17 at 15:09

1 Answers1

1

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

This question might help

Rahul Singh
  • 19,030
  • 11
  • 64
  • 86