I have a loop on twig, on which I'm trying to listen for changes on a checkbox, by appending an object to the index of the loop every time I check the check box.
{% for key, item in items %}
<input type="checkbox" ng-true-value="{{ item.id }}" ng-false-value="'NO'" ng-model="myCheckBox.{{ key }}">
And this is my angular controller:
$scope.myCheckBox = {}
$scope.$watchCollection('myCheckBox', function(){
console.log($scope.myCheckBox);
})
when I dump myCheckBox, every time i check the the check box, it's appending normally to my object and looks like this {"0":"1","1":"20"} (first item being the index, and second time being my item id). But, using the $watch or $watchCollection is not working, when i listen on these changes. I have already tried ($watch, true) and it isn't working, also isn't $watchCollection supposed to be the fix for that!