0

I have reproduced the issue on StackBlitz with minimal code.

Step 1: enter a word in the input then press the keyboard enter button

Step 2: a modal will be displayed

Step 3: press the enter button on the keyboard

in step 2 i get the bellow error:

ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'ng-untouched: true'. Current value: 'ng-untouched: false'.

step 3 should close the modal, but the modal closes then is reopened, however, when i press the confirm button with the mouse, it closes the modal properly.

3 Answers 3

0

The issues is you have modal open on the enter event as you press enter on confirm button it close the modal but also fire the event related to your text box.

(keyup.enter)= 

so it's like as you press enter first modal close then your input box event fire then as per logic modal open again. You can confirm this by changing your event to just keyup. then with every key you will have same issues as you reported for enter.

(keyup)= 
Sign up to request clarification or add additional context in comments.

Comments

0

To deal with ExpressionChangedAfterItHasBeenCheckedError: place the methods that's changing the value inside set timeout

 setTimeout(() => { // Method changing the value of property },0); 

Comments

0

If you want to get rid of this issue one way is to add a flag and toggle it.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.