first time I\'ve posted a question on here, so apologies in advance if I breach any Stack Overflow etiquette! :-)
I\'m having a go at some AngularJS for the first ti
I would bind all the checkboxes to one object say:
app.js
$scope.cartypes = {mini: false, compact:false};
index.html
<input type="checkbox" data-ng-model="cartypes.mini"> Mini
<input type="checkbox" data-ng-model="cartypes.compact"> Compact
And then create a custom filter function which returns whether the object contains all (I assume thats what you want) of the checked options.
app.js
app.filter('myfilter', function() {
return function(items, options ) {
// loop over all the options and if true ensure the car has them
// I cant do this for you beacause I don't know how you would store this info in the car object but it should not be difficult
return carMatches;
};
});
Then you can add it to your template like this:
index.html
<article data-ng-repeat="result in results | filter:search | myfilter:cartypes" class="result">
I have implemented this solution like this:
@myapp.filter "storeFilter", ->
(stores, type) ->
_.filter stores, (store) -> type[store.name]
and in the view i have passed it like that:
store in stores | storeFilter:store_type