0

I am implementing social sharing in ionic application with this plugin

Inside my page i am using ionic slides,

  <ion-slides>
    <ion-slide   *ngFor="let item of strings">
      <div>
        {{ item }}
      </div>
    </ion-slide>
  </ion-slides>

This is my typescript file to get data into slides

export class Birthday {
strings : Array<string>;
  constructor(public navCtrl: NavController, public navParams: NavParams) {
  this.strings = new Array<string>();
    this.strings.push('text1');
    this.strings.push('text2');
    this.strings.push('text3');
    this.strings.push('text4');

  }
}

Now while using social sharing plugin how to get current slide data in message field

share(**slide data heree**, subject, file, link) {
    this.platform.ready().then(() => {
        if(window.plugins.socialsharing) {
            window.plugins.socialsharing.share(message, subject, file, link);
        }
    });
}
varun aaruru
  • 2,920
  • 1
  • 20
  • 36

1 Answers1

1

Use viewChild to get the slides in component.

import { Slides } from 'ionic-angular';

@ViewChild(Slides)slides:Slides

//To get current slide,
let index = this.slides.getActiveIndex();

//Get the item as:
this.strings[index]

Documentation for slides

Suraj Rao
  • 29,388
  • 11
  • 94
  • 103