I am trying to use a function to check all checkboxes in a tree of checkboxes. It is successfully checking and unchecking, BUT if I select a single checkbox then press check all, and uncheck, the single checkbox stays as it is as freeze
HTML
<fieldset id="field3">
<table>
<tr ng-repeat="e in empdepts | groupBy:'dep_LDesc'">
<td>
<label ng-click="showContent = !showContent"></label>
<details ng-open="showContent">
<summary>
<input type="checkbox" ng-model="chk" /> {{e[0].dep_LDesc}}</summary>
<div ng-repeat="employee in e">
<input type="checkbox" ng-checked="chk"> {{employee.Sname}}
</div>
</details>
</td>
</tr>
</table>
<hr />
<table>
<tr>
<td>
<input type="checkbox" ng-model="all" ng-click="selectall(all)" /> All Departments</td>
</tr>
<tr>
<td>
<input type="checkbox" ng-model="self" /> Self Services </td>
</tr>
</table>
</fieldset>
Controller
$scope.selectall = function (all) {
if (all) {
$scope.chk = true;
}
else
{
$scope.chk = false;
}
}
LoadEmpDepts();
function LoadEmpDepts() {
Assignments.getempdepts().then(function (response) {
$scope.empdepts = (response.data);
console.log($scope.empdepts);
})
}

all?ng-click="selectall('all')"and don't forget to changeif(all)toif('all').