For that checks to see if all the elements of an array are equal to another

0

I need to make a repeat structure that traverses "N" arrays (attribute) and returns an error message if the arrays have equal elements (idoty attribute).

I tried something like:

  for(let i=0;i<this.variacaoForm.value.variacoes.length;i++){
    for(let j=0;j<this.variacaoForm.value.variacoes[i].atributo.length;j++){
      if(this.variacaoForm.value.variacoes[i].atributo[j].idtipoatributo == this.variacaoForm.value.variacoes[i+j].atributo[j].idtipoatributo){
        this.toastrService.showToast(false, "Ops, temos um problema", "Existem variações com atributos iguais!")
        this.loadingcadastro = false
      }
    }
  }

In this framework I did it does not allow this type:

Array
(
    [0] => Array
        (
            [indexvariacaoatributo] => 0
            [idatributo] => 5
            [idtipoatributo] => 1
            [tipovariacao] => Cor
            [valorvariacao] => Azul
        )

)
Array
(
    [0] => Array
        (
            [indexvariacaoatributo] => 1
            [idatributo] => 5
            [idtipoatributo] => 1
            [tipovariacao] => Cor
            [valorvariacao] => Azul
        )

)

Array
(
    [0] => Array
        (
            [indexvariacaoatributo] => 0
            [idatributo] => 5
            [idtipoatributo] => 1
            [tipovariacao] => Cor
            [valorvariacao] => Azul
        )

)
Array
(
    [0] => Array
        (
            [indexvariacaoatributo] => 1
            [idatributo] => 5
            [idtipoatributo] => 1
            [tipovariacao] => Cor
            [valorvariacao] => Azul
        )

    [1] => Array
        (
            [indexvariacaoatributo] => 1
            [idatributo] => 7
            [idtipoatributo] => 2
            [tipovariacao] => Tamanho
            [valorvariacao] => P
        )

)
    
asked by anonymous 20.11.2018 / 17:46

0 answers