Short story:, I am getting an error Expression has changed after it was checked. Previous value: 'xx'. Current value: 'xx'. when I update a variable from my component.
Long story:
I have a ParentComponent that contains the variable I am updating named totalAmount. Then I have a ChildComponent which affects the value of totalAmount but doesn't have access to the said variable. What happens is I have a subtotal variable in my ParentComponent which I pass to ChildComponent using @Input then I just recalculate the totalAmount from the ParentComponent since I have access to subtotal in it. Just like this:
ParentComponent.ts
this.totalAmount = this.subtotal + (some other values)
Then I display it on my ParentComponentTemplate.html like this:
<span>{{ totalAmount | money }}</span>
And it all works fine. Then suddenly the totalAmount had to be in an input box because there should be a way that it can be overriden. So instead of a span element I had to do it like this:
<input type="text" name="totalAmount" [(ngModel)]="totalAmount" />
Now that's when the problem starts. Everytime the subtotal in my ChildComponent changes, I get the error Expression has changed after it was checked. Previous value: 'xx'. Current value: 'xx'.
Now I've read several articles about this already that it is a feature in Angular but how do we go about this? Is there a solution to this instead of a workaround?
Thanks in advance!
<input type="text" name="totalAmount" [(ngModel)]="amountDue" />i hope this is typo you should bind textbox withtotalAmount... - Pranay Rana