I am getting problem by getting my select all button checked when there are no records.
Below is my code:
<input type="checkbox" ng-model="selectAll" ng-model-options="{getterSetter: true}"/>
var getAllSelected= function () {
var selectedItems = $scope.items.filter(function (item) {
return item.selected;
});
return selectedItems.length === $scope.items.length;
}
var setAllSelected = function (value) {
angular.forEach($scope.items, function (item) {
item.selected = value;
});
}
$scope.selectAll = function (value) {
if (value !== undefined) {
return setAllSelected(value);
} else {
return getAllSelected();
}
}
So problem is below condition is getting true when i dont have records in my $scope.items :
return selectedItems.length === $scope.items.length;
Can anybody please help me to solve this problem?
Source: AngularJS
from Angular Questions https://angularquestions.com/2017/10/05/select-all-checkbox-get-selected-by-default-when-i-dont-have-records/
via @lzomedia #developer #freelance #web #lzomedia.com
No comments:
Post a Comment