When I talk about the topic of depending on checkboxes from a dropdown list, I mention that I populate my dropdown list with data from the controller:
@RequestMapping(value = "/all", method = GET)
public List<Warehouse> findAll(){
return warehouseService.findAll();
}
$http
.get('/api/warehouses/all')
.then(function (response) {
$scope.warehouses = response.data;
});
Each Warehouse object has a List of packages:
@OneToMany
private List<Package> packages = new ArrayList<>();
Now, when creating a Route and selecting a Warehouse from the dropdown list, I want to populate the checkboxes based on the List from the currently selected Warehouse.
Select Warehouse:
<select ng-model="credentials.warehouseStart">
<option ng-selected="credentials.warehouseStart == x" id="startId" ng-value="x" ng-repeat="x in warehouse" >{{x.name}}</option>
</select>
Checkboxes:
<div flex-xs flex="50">
<md-checkbox aria-label="Select All"
ng-checked="isChecked()"
md-indeterminate="isIndeterminate()"
ng-click="toggleAll()">
<span ng-if="isChecked()">Un-</span>Select All
</md-checkbox>
</div>
<div class="demo-select-all-checkboxes" ng-model="credentials.packages" flex="100" ng-repeat="item in packages">
<md-checkbox ng-checked="exists(item, selected)" ng-click="toggle(item, selected)">
{{ item.name }} <p> </p>
{{ item.user.firstName }} {{ item.user.lastName }}
</md-checkbox>
</div>
Checkbox population:
$http
.get('/api/package/all')
.then(function (response) {
$scope.packages = response.data;
});
Is it possible to retrieve an object ID when selecting an object in the dropdown list (Warehouse)? Then I believe I can obtain the correct checkboxes using the directive /package/all/{id}.