How can I display array index value in console window on click of the button which is present inside the carousel component? where the console window is displaying index value twice and at last its redirecting to 1st array index value as 1. Console window should only display the index value with increment of 1 so it starts displaying array index value from.
guide.html
<tr *ngFor="let guide of guides">
<td>{{guide.Type}}</td>
<td>{{guide.PageColor}}</td>
<td>
<carousel class="carousel slide" data-interval="false">
<slide *ngFor="let image of images; let i=index ">
<p>Image: {{i+1}}</p>
<img src="{{image.image}}" alt="First slide"/>
<p (click)="idValue(i)">
<input type="file" name="file" id="file" />
<label for="file">{{image.change}}</label>
</p>
</slide>
</carousel>
</td>
</tr>
guide.component.ts
import { Component } from '@angular/core';
import { CarouselModule } from 'ngx-bootstrap';
@Component({
templateUrl: './guide.html'
})
export class GuideComponent {
guides : any = [{ Type: 'Company', PageColor: 'red'},{ Type: 'Company', PageColor: 'Blue'}];
images:any = [{image :'img1.jpg', change:'change'},{image: 'img2.jpg', change:'add'},{image:'img3.jpg', change:'edit'},{image:'im4.jpg',change:'delete' }];
idValue(i) {
i=i+1;
console.log(i);
}
}
<p (click)="$event, idValue(i)">in in component:idValue(event, i) { i=i+1; console.log(event, i); }and check the output.