0
I have an object that I receive from a request, I am trying to put the value of this attribute in the template but it does not appear in the textarea.
for(let i=0;i<this.produtosConfirmadosAnuncio.length;i++){
if(this.produtosConfirmadosAnuncio[i].descricao_b2w == null){
console.log('entrou no nulo')
this.produtosConfirmadosAnuncio[i].descricao_b2w = {descricao: null, id: null};
}
}
In this function I check if the descricao_b2w is null, if it is I create keys and values with null value (I did this because I was giving error in the template when the descricao_b2w object was null, so I could not find the Description key, claimed that it was Undefined).
My template:
<div *ngFor="let produto of produtosConfirmadosAnuncio; let i = index" class="col-xl-4">
<textarea class="form-control"
name="message"
rows="3"
[(ngModel)]="produto.descricao_b2w.descricao"
#message='ngModel'
>{{produto.descricao_b2w.descricao}}</textarea>
I also tried to:
<textarea class="form-control"
name="message"
rows="3"
[(ngModel)]="produto.descricao_b2w.descricao"
#message='ngModel'
>{{produto.descricao_b2w.descricao}}</textarea>
and also tried to:
<textarea class="form-control"
rows="3"
[(ngModel)]="produto.descricao_b2w.descricao"
></textarea>
Parser Error: The '?. ' Operator cannot be used in the assignment at at
– veroneseComS
I think you need to put in the previous one too, take a look now
– renanvm
made the same mistake, but I got it here, thank you
– veroneseComS
changed again
– renanvm