2017-03-18 94 views
0

我實現離子應用社會化分享與this plugin實施離子幻燈片

在我的網頁我使用離子滑梯內的社會共享,

<ion-slides> 
    <ion-slide *ngFor="let item of strings"> 
     <div> 
     {{ item }} 
     </div> 
    </ion-slide> 
    </ion-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'); 

    } 
} 

現在在使用社交分享插件時如何獲得消息字段中的當前幻燈片數據

share(**slide data heree**, subject, file, link) { 
    this.platform.ready().then(() => { 
     if(window.plugins.socialsharing) { 
      window.plugins.socialsharing.share(message, subject, file, link); 
     } 
    }); 
} 

回答

1

使用viewChild獲取組件中的幻燈片。

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] 

的文檔slides