Angular filtering
by Vladimir
HTML
<div ng-app="shopApp" ng-controller="ProductsController as ctrl">
<label><input type="checkbox" ng-model="filtr.red">red</label>
<label><input type="checkbox" ng-model="filtr.white">White</label>
<label><input type="checkbox">Grey</label>
<div>{{filtr}}</div>
<div ng-repeat="product in ctrl.products | filter:filterColors">
<p>{{product.color}}</p>
</div>
</div>
JavaScript
var app = angular.module('shopApp',[]);
app.controller('ProductsController', ProductsController);
function Product(color){
this.color = color;
}
function ProductsController(){
this.products = [
new Product('red'),
new Product('white'),
new Product('grey'),
new Product('red'),
new Product('white'),
new Product('grey')
];
this.filterColors = function(value, index, array) {
console.log(12);
return false;
};
}