Encountering an issue while trying to generate a dynamic class name based on the ngFor loop index in Angular 2. Due to restrictions, I had to use a specific syntax as Angular 2 does not support ngFor and ngIf together on the same element.
Given this setup, how can I dynamically set a class name using the value of index at {{index}}
? Although this may not adhere strictly to A2 standards, I included it in the example code to indicate where I aim to insert the value.
<div class="product-detail__variants">
<template ngFor #variant [ngForOf]="variants" #index="index">
<div *ngIf="currentVariant == index">
<div class="product-detail-carousel-{{index}}">
</div>
</div>
</template>
</div>
The variable "variants" stands for an empty array with a specific length, hence "variant" holds no actual value.
"currentVariant" denotes a number that typically begins at 0.
UPDATE: The provided code is accurate. My previous issue stemmed from an unrelated error that I mistakenly associated with this piece of code.