So i have JSON data of HVAC businesses and I want to filter them by their certification array using an HTML checkbox. The following code is a simple version of what i'm working with |filter and ng-model removed
angular.module("list",[])
.controller("listController",[listCtrlFun])
function listCtrlFun(){
this.businesses = [
{
"name": "HotCold",
"certifications": ["Residential","Installation"]
},{
"name": "MegaCorp",
"certifications": ["Commercial","Installation"]
}];
}
<div ng-app="list" ng-controller="listController as vm">
<div>
<label>
<input type="checkbox" />
Residential
</label>
<label>
<input type="checkbox" />
Commercial
</label>
<label>
<input type="checkbox" />
Installation
</label>
</div>
<div ng-repeat="business in vm.businesses">
<p>{{business.name}}</p>
</div>
</div>
The goal is so that when someone checks Installation both businesses show up and if they check Commercial and Install only that one will show up. I am not sure how to bind the values from the checkboxes so that they can be crossed referenced against the data. I have tried something like this...
this.types = {Residential: true, Commercial: true, Installation: true} here and I can get the values to change when I bind them to the checkboxes. Still i am unsure how to cross reference the true/false value with the data