I have some data for my checkbox here,
$scope.dataList = {
'ICT': true,
'OTTIX_DT': true,
'CP EMR AD': true,
}
<input type="checkbox" ng-model="miniAddons.dataList[data.jobName]"
ng-change="pickExtra($event,'miniAddons', chosenMiniAddons, data.jobName);">
$scope.pickExtra = function(evt,JBname,chosenMiniAddons,chosenOptions){
$scope.userSelectedMiniAddon = Object.keys($scope[miniAddons].dataList);
}
My goal is to control button enable/disable based on the selection, by using the results of
var temp = Object.keys($scope.dataList)
where I get the keys as an array and check its length. If the length
is greater than 0, I enable the button, otherwise, I disable it.
When I click on a checkbox, I see the array items increasing as expected. However, I am unsure how to remove items when unchecking the checkbox.
In simple terms, if all values in $scope.dataList
are set to false
, then I need to disable the button. The button should only be enabled if at least one key has a value of true
.
I am currently using old-fashioned JavaScript, without even any ES6 features, and I am confused about how to perform filtering and mapping operations in this context.
I would appreciate any help on this matter.