Ngx-quill: Infinity loop in changes

Created on 9 Jul 2020  路  3Comments  路  Source: KillerCodeMonkey/ngx-quill

This is a continuation of a past problem.

  1. I'm set initial value with ngModel:
    <span style="background-color: rgb(213, 227, 227); color: rgb(0, 0, 0);">Hi</span>

  2. 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>

  3. 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 :>

Most helpful comment

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()"

All 3 comments

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)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

agam16 picture agam16  路  5Comments

anthonyinspace picture anthonyinspace  路  3Comments

luksireiku picture luksireiku  路  5Comments

jadamconnor picture jadamconnor  路  5Comments

Rlcolli4 picture Rlcolli4  路  3Comments