So I'm trying to exibit information from an array of strings. This array includes data that may change from one element to another (like one has contact information, the other has contact information and address, etc).
I was trying to exibit the element, but I can't. Here's my HTML snippet:
<ul *ngFor="let dp of consentimento.dadosPessoais">
<li>
{{dp}}
</li>
</ul>
I can already access other data in "consentimento", but not this array in this *ngFor. If I simply put {{consentimento.dadosPessoais}} outside of the loop I get [object Object].
The console gives me this error:
core.js:4352 ERROR Error: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.
at NgForOf.ngDoCheck (common.js:3193)
at callHook (core.js:3109)
at callHooks (core.js:3075)
at executeInitAndCheckHooks (core.js:3027)
at selectIndexInternal (core.js:6264)
at Module.ɵɵadvance (core.js:6246)
at DialogDetalharConsentimentoComponent_Template (dialog-detalhar-consentimento.component.html:62)
at executeTemplate (core.js:7449)
at refreshView (core.js:7318)
at refreshComponent (core.js:8465)
I've been trying this for three days now, with zero success. I really need some help.
import { ActivatedRoute } from '@angular/router';
import { TemplateConsentimentoDTO } from '../../../../model/template.dto';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
import { Component, OnInit, Inject } from '@angular/core';
@Component({
selector: 'app-template-dialog',
templateUrl: './template-dialog.component.html'
})
export class TemplateDialogComponent implements OnInit {
acao:string="";
idEmpresa:number=0;
idTemplate?:number;
constructor(
public dialogRef: MatDialogRef<TemplateDialogComponent>,
private route: ActivatedRoute,
@Inject(MAT_DIALOG_DATA) public template: TemplateConsentimentoDTO){}
ngOnInit(): void {
this.route.queryParams.subscribe(params=>{
this.acao=params['acao'];
this.idEmpresa=params['uuid'];
this.idTemplate=params['template'];})
}
onNoClick(): void {
this.dialogRef.close();
}
}
By the way, here's the DTO for consentimento:
export class ConsentimentoDTO {
public id: string | undefined;
public idTemplate: number | undefined;
public idEmpresa: number | undefined;
public nomeTemplate: string | undefined;
public descricaoTemplate: string | undefined;
public cpfCoresponsavel: string | undefined;
public cpfResponsavel: string | undefined;
public dataInicio: Date | undefined;
public dataFim: Date | undefined;
public status: string | undefined;
public dadosPessoais?: string[]| undefined;
public tratamentoDados: string[]| undefined;
public template: TemplateConsentimentoDTO | undefined;
public dataSolicitacao: Date | undefined;
public solicitante: string | undefined;
public empresaSelecionada: EmpresaElement | undefined
}