1
I am running a repeat structure to check which fields of my form are invalid. I need to get the name of the first field that is invalid.
I tried something like:
for(var campoObrigatorio in formulario.controls){
if(formulario.controls[campoObrigatorio].status == "INVALID"){
var displayCampoObrigatorio = formulario.controls[campoObrigatorio];
console.log(displayCampoObrigatorio)
return ;
}
}
Apparently my logic is correct, but I’m not getting the name of the object in this line:
var displayCampoObrigatorio = formulario.controls[campoObrigatorio];
Here it takes all the gift tree of the field that is with invalid status, I would like the name of the object. Ex: height, length, etc...
That’s right, I switched to console.log(fieldObrigatorio) and got the result I needed.
– veroneseComS