I have the following Json structure on my project:
"disputas": [
{
id: "",
tipo_negociacao: "",
historico:[{
fl_usuario: "",
created_at: "",
updated_at: "",
created_by: null,
updated_by: null,
texto: "",
}]
}
]
I want to add a new index of historico
when I click on a button but don't know how to do it, I want it to look like this:
"disputas": [
{
id: "",
tipo_negociacao: "",
historico:[{
fl_usuario: "",
created_at: "",
updated_at: "",
created_by: null,
updated_by: null,
texto: "",
},
{
fl_usuario: "",
created_at: "",
updated_at: "",
created_by: null,
updated_by: null,
texto: "",
}
]
}
]
So far, I've done something like this (function that the button calls):
recusaProposta() {
this.disputa.historico[this.i].texto = "something";
this.i++;
}
now, since i
starts on 0
this works on the first time I click on the button, but if I click on it again I'll get this error:
Cannot set property 'texto' of undefined
Can someone help me? thanks