Error delete element from array typescript

1

Good I am trying to erase a element of the array that I have with the splice but it is petando me and I do not know why.

is not an array of objects so I should leave

borrarTurno(turno:string){
    let index= 0;
    for (let turnoABorrar of this.datosTurnos) {
       if (turnoABorrar.turno == turno){
          this.datosTurnos[index].splice(index,1);    
       }
       index++;
    }
  }

This is the method that I have in the .ts and in the browser I peta

  

AdjustmentsComponent.html: 93 ERROR TypeError: turnBack.splice is not a   function       at

...

    
asked by juanPedro46 28.11.2018 в 23:17
source

1 answer

0

Try this:

borrarTurno(turno:string){
  datosTurnos.splice(datosTurnos.indexOf(dato => dato.turno === turno), 1);
}
    
answered by 29.11.2018 в 08:09