0
I have this method that gets the list date, what works, after a query in the database.
private preencherPlanosSaudes() {
this.planoSaudeService.buscarTodos().subscribe(
(data : any[]) => {
let ps = new EnumModel();
ps.key = data[0].id;
ps.texto = data[0].nome;
this.planosSaudes.push(ps);
}
);
}
But inside the subscribe, I need an accountant to look like this:
private preencherPlanosSaudes() {
let contador = 0;
this.planoSaudeService.buscarTodos().subscribe(
(data : any[]) => {
let ps = new EnumModel();
ps.key = data[contador].id;
ps.texto = data[0contador].nome;
this.planosSaudes.push(ps);
contador ++;
}
);
}
But it doesn’t work. What I’m doing wrong ?
how do you know it doesn’t work?
– guijob