to see if they can tell me why this happens. The thing is that I have a double ng-repeat where two lists are traversed. The first list is a list of contractors and within this list there is another list of documents. That is, the contractors have a list of documents associated with them.
To go through the two lists within the HTML I have the following code:
<accordion close-others="true" ng-repeat="contratista in listaContratistas track by $index | filter:{activo:'S'}">
<accordion-group heading="{{contratista.razonSocial}}">
<button ng-click="delContratista($index);" class="btn btn-block btn-danger btn-xs">Eliminar Contratista</button>
<p>Documentos obligatorios:</p>
<div ng-repeat="documento in contratista.documentosProyecto track by $index">
<div class="checkbox" ng-click="$parent.delDocumentoContratista($parent.$index, $index);" >
<!--<div class="checkbox" ng-click="$documento.obligatorio == 'S'? documento.obligatorio = 'N' : documento.obligatorio = 'S'" >-->
<label>
<input type="checkbox" ng-checked="listaContratistas[$parent.$index].documentosProyecto[$index].obligatorio == 'S'">
<!--<input type="checkbox" ng-checked="documento.obligatorio == 'S'">-->
{{documento.tipo}}
</label>
</div>
</div>
</accordion-group>
</accordion>
The documents that contractors have have a property called mandatory, which by default is equal to 'S'.
The problem is that when you click on a check from any contractor, your check and that of all contractors is unchecked. The code in the controller is as follows:
$scope.delDocumentoContratista = function(indexContratista, indexDocument){
if($scope.listaContratistas[indexContratista].documentosProyecto[indexDocument].obligatorio == 'S'){
$scope.listaContratistas[indexContratista].documentosProyecto[indexDocument].obligatorio = 'N';
}else{
$scope.listaContratistas[indexContratista].documentosProyecto[indexDocument].obligatorio = 'S';
}
}
I have already tried countless things and it still does not work. What is wrong with the code for this to happen to me?
Greetings and thank you very much.