This is a continuation of a past problem.
I'm set initial value with ngModel:
<span style="background-color: rgb(213, 227, 227); color: rgb(0, 0, 0);">Hi</span>
When called onContentChanged, I'm set new value with ngModel:
<span style="color: rgb(0, 0, 0); background-color: rgb(213, 227, 227);">Hi</span>
When called onContentChanged again, I'm set new value with ngModel:
<span style="background-color: rgb(213, 227, 227); color: rgb(0, 0, 0);">Hi</span>
After this, step 2 and 3 are repeated endlessly.
This is not the behavior we expect.
If you do not understand, I can do a quick demo project :>
sure it will result in an endless loop, use ngModel or formControl and not listen to onContentCHanged
because changing the model will trigger content change and you are setting the model in the callback.
just use [(ngModel)] or if you want to do something else when the model changes, then [(ngModel)]="xxxx" (ngModelChanged)="callbackWhenChanged()"
Yes, I didn鈥檛 notice, thank you very much)
@KillerCodeMonkey
just use
[(ngModel)]or if you want to do something else when the model changes, then[(ngModel)]="xxxx" (ngModelChanged)="callbackWhenChanged()"
To avoid future problems, its (ngModelChange) not (ngModelChanged)
Most helpful comment
sure it will result in an endless loop, use ngModel or formControl and not listen to
onContentCHangedbecause changing the model will trigger content change and you are setting the model in the callback.
just use
[(ngModel)]or if you want to do something else when the model changes, then[(ngModel)]="xxxx" (ngModelChanged)="callbackWhenChanged()"