0

ng click or ng-change not working in toggle button. I use toggle-bootstrap package here

<input checked 
       data-toggle="toggle" 
       data-size="small" 
       type="checkbox"
       data-on="16x9" 
       data-off="4x3"
       ng-true-value="'16x9'"
       ng-false-value="'4x3'"
       ng-model="slideMode" 
       ng-change="setSlideMode()">

Angular code

 $scope.slideMode = '16x9';
 $scope.setSlideMode = function(){
        console.log($scope.slideMode);
 };
6
  • can you share working code? Commented Aug 10, 2016 at 6:07
  • see there can be so many possibilities for which your might not working so you need to share some working environment with us Commented Aug 10, 2016 at 6:12
  • code typo for the value set to $scope.slideMode ! Commented Aug 10, 2016 at 6:15
  • check now @GopinathShiva Commented Aug 10, 2016 at 6:18
  • 1
    creating a fiddle would be more useful indeed Commented Aug 10, 2016 at 6:19

2 Answers 2

3

you should add ngModel directive to input component:

 <input
    ng-model="check"
   data-toggle="toggle" 
   type="checkbox" 
   ng-change="test()">

than add check variable to your controller

 $scope.check = true;

here is the plunker example: https://plnkr.co/edit/r21V3E4upBNxIm16zakj?p=preview

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

7 Comments

plunkr not working. neither it shows checkbox nor atleast the name rendered
add this but stil not working i use bootstap toggle here
hey I update plunker, it was my mistake shared wrong url, sorry @ismailbaig
thanks. removing the down-vote and adding the up-vote :)
I think you should use ui-bootstrap or twitter bootstrap toggle. Or check this project's issues and make sure that this component can use with angularjs directive synchronously. @GurpreetSingh
|
2

Set scope value syntax is wrong.

$scope.slideMode = '16x9';

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.