0
I have the following model:
produtosConfirmadosAnuncio.model.ts
:
export class ProdutosConfirmadosAnuncio{
idContasAnunciarB2W:[{id: number}];
}
I start it this way:
produtosConfirmadosAnuncio: ProdutosConfirmadosAnuncio[] = []
At a certain point in my application I should add an object to that Array
:
if(this.contasB2W[i] == event.option.viewValue){
console.log(this.idContasB2W[i])
this.produtosConfirmadosAnuncio[index].idContasAnunciarB2W.push({id: this.idContasB2W[i]});
}
And then I get on the line that contains the push
:
ERROR Typeerror: Cannot read Property 'push' of Undefined
In that console.log
value 22 shall be printed.
The variable index exists?
– LeAndrade
Yes, I’ve figured out the problem, I’ll add an answer
– veroneseComS