I have an empty array that I'm just pushing integers into. However, the console.logs print am empty array [ ] everytime I trigger this function in my view:
html:
<div ng-repeat="color in colors">
{{color.name}} <input type="checkbox" ng-model="color_ids" ng-change="toggleColorFilter(color.id)">
</div>
angular:
app.controller('IndexCtrl', ['$scope', "Product", "Color", function($scope, Product, Color) {
...
$scope.color_ids = [];
$scope.toggleColorFilter = function(color_id) {
var index = $scope.color_ids.indexOf(color_id);
if (index > -1) {
$scope.color_ids.push(color_id);
} else {
$scope.color_ids.splice(index, 1);
}
console.log($scope.color_ids);
};
}]);