The angular solution can be seen here: http://plnkr.co/edit/j63po37JBvc3bFdNAl3T
It's basically sending the event on ng-change
<div class="checkbox" ng-repeat="product in products">
<input type="checkbox" ng-model="product.selected" ng-change="add(product)"/> {{product.name}}<br>
</div>
and I'm considering your controller to be like this:
app.controller('myController', function($scope){
$scope.products = [
{'name':'product1', 'selected': false},
{'name':'product2', 'selected': false},
{'name':'product4', 'selected': false}
];
$scope.selected_products = [];
$scope.add = function(prod){
var index = $scope.selected_products.indexOf(prod.name);
if(index == -1 && prod.selected){
$scope.selected_products.push(prod.name);
} else if (!prod.selected && index != -1){
$scope.selected_products.splice(index, 1);
}
}
})
So, you have a list of product objects that have a name and the selected state, you use the checkbox to keep the selected state there, and when you mark/unmark it, the ng-change event is triggered, passing to the add function in the scope the product, you then check the product.name index on the selected_products array, if it's not there, you add it, if it is already there, remove it. This way selected_products matches the selected checkboxes.