Checkbox + ngmodel + ngchange + dialog

hello,

i have checkbox that open a dialog when checked.

  • this dialog is composed with a validation button and a cancel button.
  • my checkbox tag have an [(ngModel)] and (ionChange).

the problem is :

when user press cancel button ([(ngModel)] value become false to uncheck the checkbox) but (ionChange) is called in same time and reopen my dialog a second time.

how can i handle that ?

This is like the story of the person who goes to the doctor and says “Doc, it hurts whenever I bash my head against the wall. What should I do?”.

[(ngModel)]="foo" is, under the hood, effectively [ngModel]=foo (ngModelChange)="foo = $event". You have created a situation where multiple conflicting things are happening when the checkbox is clicked.

Like the person in the story, it will stop hurting if you stop bashing your head against the wall. Either remove the banana binding on [(ngModel)], leaving only [ngModel]), and handle updating the value in the (ionChange) handler, or get rid of (ionChange).

:blush: it was a bad question and i found solution by checking value before display the dialog.

i don’t know why i did not think it, but this doctor story helped me to see the good proceedings ^^

tiiii