Angular 2: NgFor without an HTML tag?

I want to create ngFor Loop without a div tag.

How is this possible?

My problem is that when I use 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 any other way to use ngFor without this div container?

Thank you so much!

+4
source share
2 answers

ng container could be better.

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

<ng-container *ngFor="let i of items" >
{{i.name}}
</ng-container>
+9
source
<template ngFor let-set [ngForOf]="exercise.sets" let-setNumber="index">
// ...
</template>
+4
source

Source: https://habr.com/ru/post/1661447/


All Articles