0
why is returning only the last position of the array instead of all ???
showChildModal3(Candidato: Candidato) {
this.CandidatoService.getCandidatoById(+Candidato.id)
.subscribe( data => {
for (let c of Candidato.veiculos) {
this.selectedObjects = []
this.selectedObjects.push([c.id]);
this.formularioEdit.patchValue(
{
nome:Candidato.nome,
email: Candidato.email,
cpf: Candidato.cpf,
rua: Candidato.rua,
bairro: Candidato.bairro,
cidade: Candidato.cidade,
UF: Candidato.UF,
tipo: Candidato.tipo_cliente,
veiculos: this.selectedObjects
});
}
});
this.lgModal3.show();
}
I read in the comments that you are using Primeng. In case you want to list the items in a table?
– Edward Ramos
i have an array of obejtos coming from an api
– Grood
From what I understand of your code, you are doing: 1- Receiving an object
Candidato
by parameter. 2 - Searching for aCandidato
forService
(you have already received the object by parameter). 3- You are making afor
ofCandidato.veiculo
(did not understand this part). 4- Always at the beginning offor
you empty theselectedObjects
and inserts aid
inside (that way, there will always be only oneid
in the array). 5- NopatchValue
you are taking the values that come from the object that is in the parameter, and not from thedata
returning from service.– Edward Ramos