i currently have an array of objects i use to generate html checkboxes (ng-repeat). All those objects have an x.checked = true / false attribute. How can i set this x.checked = false for all objects at once?
Right now i use a simple for loop.
for(var i = 0; i < array.length; i++) {
array[i].checked = false;
}
Does Angular have a faster or shorter way of doing this?
Thanks!
There is no way to do it per se, no matter how you write it, you will never do it all at once, it will at best be a shorthand for what your wrote above.
Yes , You can use angular.forEach for this, Like so:
angular.forEach(array, function (item) {item.checked = false;}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With