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

407
Visualizações
How can I repeat content (aka *ngFor) without a wrapping element?

I have an Angular 4 component that uses what is effectively a 2d array. I have an array of sections which hold an array of links. I want to be able to output them all flatly:

<ul>
  <div *ngFor="let section of all_sections">
    <li *ngFor="let nav of section.links" [class.active]="nav.href === current_url">
    </li>
    <li class="divider"></li>
  </div>
</ul>

How can I force it to do the loops but without the extra wrapping div for the sections? It should just be li tags inside the ul.

Expected output:

<ul>
    <li class="active"></li>
    <li class="active"></li>
    <li class="active"></li>
    <li class="divider"></li>
    <li class="active"></li>
    <li class="active"></li>
    <li class="active"></li>
    <li class="divider"></li>
</ul>
about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

you can try using ng-container

<ng-container *ngFor="let section of all_sections;">
 ...
</ng-container>
about 4 years ago · Santiago Trujillo 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