Question

I have used switch-toggle inside ng-repeat. I don't know how to set default value to ng-model when you have multiple switch-toggle in your form and on form submit you need to have all the values. I am very much new to angular world and here is the Example In this example on form load the default value for switch-toggle is shown as "OFF". And if I submit form without making any change to the switch-toggle and check in browser console you can see empty model array. And on making some changes then I get the appropriate values.
So, how can I get all the values of the switch-toggle irrespective I make changes or not. As far as my angularJS knowledge is concern I guess it is related to its model. But how to do it in this case I feel I am lost.

Was it helpful?

Solution

This i believe should be model driven. You should intialize your switchModel, something like this

$scope.switchModel = {1:false,2:true,3:false };

instead of {}

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top