Estoy programando el típico seleccionar/deseleccionar todo, lo hace todo bien excepto una cosa, si selecciono a mano un par de elementos y después le doy a seleccionar todos se queda el array
vacío.
seleccionarTodo() {
if (this.capturaCochesId.length === 0) {
for (let selec of this.coches) {
this.capturaCochesId.push(selec.id);
this.check = "checked";
}
} else {
this.check = "";
this.capturaCochesId = [];
}
console.log(this.capturaCochesId);
}
<input type="checkbox" (change)="seleccionarTodo()"> SELECCIONAR TODO