Repeating structure not verifying null elements?

0

I have two repeating structures that traverses my element and checks to see if the "attribute attribute" is null.

If my object has two elements, only the first id attribute is being printed. The second is null, I made a validation to zero the object if id is null.

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++){
      console.log("idatributo:  "+this.variacaoForm.value.variacoes[i].atributo[j].idatributo)
      if(this.variacaoForm.value.variacoes[i].atributo[j].idatributo == null){
        console.log('entrou na condicao');
      }
    }
  }

You are not entering the if condition.

My object:

variacoes: (2) […]
​​
0: {…}
​​​
atributo: (1) […]
​​​​
0: {…}
​​​​​
idatributo: 5

1: {…}
​​​
atributo: {…}
​​​​
idatributo: null

In short, I have two variations, within the varations I have an attribute, in one of these attributes has null idatribution, I would like my object (attribute) to be reset in this condition.

If I change the id of the second attribute it usually prnits, the problem is that the condition is not being made

    
asked by anonymous 21.11.2018 / 12:53

1 answer

0

this.variacaoForm.value.variacoes [i] .attribute [j] .id attribute == 'null'

    
21.11.2018 / 20:20