1

I am trying to use data-toggle="toggle" (from: http://www.bootstraptoggle.com/ ) on a checkbox. However, this breaks angulars ng-click and ng-change... They are simply not firing the function. Does anyone have a solution for this? Code snippet below:

<input type="checkbox"  
       ng-click="testFunction()" 
       ng-model="testValue" 
       checked 
       data-toggle="toggle">
4
  • You don't seem to have an ng-change in the code. Also have you tried wrapping the testFunction() in double quotes? Either way a Plunkr would be useful Commented Jul 17, 2016 at 11:35
  • i tried with both ng-change or ng-click, both dont work. Commented Jul 17, 2016 at 11:36
  • 2
    Ok The reason it doesn't work is that Bootstrap Toggle is not made to work with Angular. Changing the DOM in any way that isn't through Angular, eg through jQuery like Toggle does, will cause conflicts with Angular's control of the DOM, and indeed it will not register DOM changes that don't happen through Angular. Commented Jul 17, 2016 at 11:47
  • If that answer helped I will post it as an answer and please accept it :) Commented Jul 17, 2016 at 12:13

1 Answer 1

2

The reason it doesn't work is that Bootstrap Toggle is not made to work with Angular. Changing the DOM in any way that isn't through Angular, eg through jQuery like Toggle does, will cause conflicts with Angular's control of the DOM, and indeed it will not register DOM changes that don't happen through Angular.

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

Comments

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.