I have created two separate lists.
1) The first list contains the service names.
2) The second list contains the product names assigned to each service name.
Each product has a unique ID that matches it with its corresponding service.
app.controller('loadProductServicesCtrl',function($scope){
$scope.services = [
{"ServiceID": 1, "ServiceName": "Telecommunications"},
{"ServiceID": 2, "ServiceName": "Energy"},
{"ServiceID": 3, "ServiceName": "Private Health Insurance"}
];
$scope.products = [
{
"ProductID": 9,
"ServiceID": 1,
"ServiceName": "Telecommunications",
"ProductName": "Business 500",
"ProductProfit": 40,
"ProductTooltip":""
},
{
"ProductID": 10,
"ServiceID": 2,
"ServiceName": "Telecommunications",
"ProductName": "Business 1000",
"ProductProfit": 50,
"ProductTooltip": ""
},
{
"ProductID": 11,
"ServiceID": 3,
"ServiceName": "Telecommunications",
"ProductName": "Business W",
"ProductProfit": 75,
"ProductTooltip": ""
}
];
});
<div class="form-group">
<label for="selectpicker" class="margin-r-5 form-label">Select Service</label>
<select data-ng-model="myService" data-ng-options="service as service.ServiceName for service in services" class="selectpicker services">
<option value="">Select Service</option>
</select>
</div>
<div class="form-group products">
<div class="checkbox checkbox-primary checkbox-inline" ng-repeat="x in products">
<input type="checkbox" id="{{ x.ProductID }}" value="option1">
<label for="{{ x.ProductID }}"> {{ x.ProductName }} </label>
</div>
</div>
I am trying to filter the products based on the selected service ID. I attempted to use the ng-model on the select element, but it doesn't seem to be working correctly. Do you have any advice on how to achieve this?