0

i have an issue, (change) function is not firing in that checkbox.

 <input [(ngModel)]="driver.glasses" name="glasses" type="checkbox" class="make-switch"
   (change)="changeFuntion()"  data-on-color="primary" data-off-color="info">

But in this one it works

    <input [(ngModel)]="driver.glasses" name="glasses" type="checkbox" 
   (change)="changeFuntion()"  data-on-color="primary" data-off-color="info">

I have noticed that class="make-switch" is the problem, because in the first checkbox with that class, (change) don´t work. How I can solve this, I need to apply class="make-switch" to make switch checkbox.

7
  • what does make-switch class has? does it has any events? Commented Jul 21, 2017 at 5:19
  • when you are using [(ngModel)] go with ng model change (ngModelChange)="onChange($event)" Commented Jul 21, 2017 at 5:26
  • make-switch class does input toggle, and it doesn´t have events. Commented Jul 21, 2017 at 5:31
  • I test with (ngModelChange), but don´t work Commented Jul 21, 2017 at 5:33
  • Can you share make-switch class? Commented Jul 21, 2017 at 6:19

1 Answer 1

2

You can use ngModelChange like this :

This is your component.ts

checkboxValue: any;

changeEvent(event: any) {
    console.log(event);
  }
<input type="checkbox" [ngModel]="checkboxValue" (ngModelChange)="changeEvent($event)" data-md-icheck/>

Sign up to request clarification or add additional context in comments.

6 Comments

Please check the comment over the question. That he has already tried with ngModelChange but that does not work.
code example does not exist in comment , that is why i posted that
But that is not the correct answer right? As questioner has already mentioned it. He doesn't need code example here. He need solution. And this answer does not provide any.
my answer is correct and it works everywhere, if he tries that and that does not work , it means problem is not relating to change event
My friend check question properly. Check the scenario when it is not working. I know this works for you but for his scenario with class which he has mentioned is not the proper answer.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.