4
How do I check input’s checkbox? You’re just unchecking.
Follow the codes for assistance:
HTML
<div class="col-md-11">
<div style="text-align: right;" class="checkbox">
<label><input type="checkbox" ng-click="marcarDesmarcarTodos('checkParticipantes')" id="ckeckAll" name="checkAll" />Marcar/Desmarcar Todos</label>
</div>
</div>
<input type="checkbox" name="checkParticipantes" ng-click="ckeckMarcarDesmarcarTodos()" ng-model="participante.selecionados[pessoa.ID_PESSOA_EVENTO]" />
Javascript - Angularjs
$scope.ckeckMarcarDesmarcarTodos = function () {
if( $('#ckeckAll').is(':checked')) {
$('#ckeckAll').prop("checked", false);
}else {
$('#checkAll').prop("checked", true);
}
};
$scope.selectedAll = false;
$scope.marcarDesmarcarTodos = function ()
{
$scope.selectedAll = !$scope.selectedAll;
if ($scope.selectedAll) {
$scope.participante.selecionados = {};
angular.forEach($scope.participante, function (item) {
$scope.participante.selecionados[item.idPessoaEvento] = $scope.selectedAll;
});
} else {
$scope.participante.selecionados = {};
}
};
Wagner, it’s still the same.
– Leufrasio
Wagner, unfortunately it didn’t work !
– Leufrasio
How are the checkboxes that will be checked/unchecked? put their code there to see.
– Wagner Soares
Wagner, I edited the codes again below the question, as you requested.
– Leufrasio
Put an id in the checkbox so id="checkParticipants", then in the script change to $('#checkParticipants'). prop( "checked", false ); and $('#checkParticipantes'). prop( "checked", true);
– Wagner Soares