I’ve got an array of numbers that I’d like to display as a selection of check boxes that the user can then check/uncheck, and what I’d like to do is to then have another array of values created that represent the checked check boxes.
So, for example, my options are:
$scope.options = [500, 1250, 2500, 5000, 10000, 25000, 50000, 100000];
My second array is:
$scope.selected = [1250, 2500, 5000, 10000, 25000];
I’d like to build a form that looks something like:
[ ] 500
[x] 1250
[x] 2500
[x] 5000
[x] 10000
[x] 25000
[ ] 50000
[ ] 100000
And have the second array update depending on the values that are checked/unchecked in the form. I think I know how to get the form built by using ngRepeat on the first array, and setting the checked flag for the check boxes should be simple enough, but what I’m not sure on is how to get the second array updated.
Is there a relatively simple way of doing this?
Any help is greatly appreciated! Thanks,
Dylan