Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

190
Visualizações
Data is shown in the console but not in the website Angular

This is my ngOnInit method:

async ngOnInit() {
    
    return this.http.get(this.apiserver.apiUrl + 'negocios/listadoTodos/?negocio=1').subscribe(async (todos:any) => {
        this.detalles = todos;
        console.log(this.detalles);
        
      });
    
}

My console: enter image description here

My Html:

<div class="text-lg font-bold leading-none" *ngFor="let item of detalles">{{item.nombre}} - {{item.sector}}</div>

Im trying to use an api that is on my localhost and idk why at the console it is working but not in the frontend html.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Your API might tacking time to load data so when API call get data it will print data in console but before that your HTML render on browser, so you need to use *ngIf before you *ngFor like this.

<div *ngIf="detalles.length">    
    <div class="text-lg font-bold leading-none" *ngFor="let item of detalles"> 
         {{item.nombre}} - {{item.sector}}
    </div>
</div>
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda