I have a html page in Ionic 2 where I am generating ion-slide using *ngFor and I want to pass the data from ngFor to the footer in the same page.
<ion-content>
<ion-slides>
<ion-slide *ngFor="let event of completeEvents">
{{event.message}}
</ion-slide>
</ion-slides>
</ion-content>
<ion-footer>
<div>
<p>{{event.message}}</p>
</div>
</ion-footer>
how do I pass the event.message to the footer ?
You need to have a template variable that can be updated. Here this example uses a variable named
current.The
ionSlideDidChangeevent emits a$eventwhich is an instance reference of theSlidescomponent. So you can use that to call any of the published methods from the documentation.I'm not sure if the event is fired the first time the first slide is shown. Therefore, I added the
current || 0to always show the first.Edit:
I changed the answer so that
currentholds a reference to the current event. This makes it safer in the cases wherecompleteEventsis updated dynamically elsewhere.