Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 2: NgFor without HTML Tag?

Tags:

i want to create a ngFor Loop without a div tag.

Is this somehow possible?

My Problem is, that when i use a div *ngFor the slider is broken.

<ion-slides #secondSlider [options]="secondSlideOptions" (ionDidChange)="onSecondSlideChanged()">     <!-- This div should not be there -->      <div *ngFor="let set of exercise.sets; let setNumber = index;">         <ion-slide>         ...         </ion-slide>          <ion-slide>         ...         </ion-slide>     </div> </ion-slides> 

Is there another way to use ngFor without that div container?

Thanks a lot!

like image 737
Fargho Avatar asked Nov 21 '16 11:11

Fargho


2 Answers

ng-container may be better.

See https://github.com/angular/angular/issues/11994

<ng-container *ngFor="let i of items" > {{i.name}} </ng-container> 
like image 89
Junichi Sakaeda Avatar answered Oct 05 '22 03:10

Junichi Sakaeda


<template ngFor let-set [ngForOf]="exercise.sets" let-setNumber="index"> // ... </template> 
like image 26
rodrigocfd Avatar answered Oct 05 '22 03:10

rodrigocfd