Currently I am using angular and I have an array in typescript file like this.
var channelArray = {"channel1", "channel2", "channel3"}
In my html I have code like
<div *ngFor="let val of channelArray">
<de-series-prop></de-series-prop>
</div>
How do I pass the index of the array to series-prop component. I need the index value to assign some values in series-prop component.
<div *ngFor="let val of channelArray; let i = index">
<de-series-prop [index]="i"></de-series-prop>
</div>
In your component:
@Input()
index: Number;
*ngFor exposes the index as a local variable.
<li *ngFor="let item of items; let i = index; trackBy: trackByFn">...</li>
You can see the documentation here .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.