【发布时间】:2018-11-02 00:58:35
【问题描述】:
我在ionic3创建了一个新项目
在我的项目中;首先,我使用 PHP 将图像保存到数据库中
然后我从数据库中检索所有图像并使用photo.ts 显示在离子photo.html 中
它成功了。但是我需要在ionic3中添加共享选项。
如果用户单击共享按钮,该特定图像将在用户社交媒体(fb、twitter、whatsapp)上共享。如何做到这一点?
这里是html代码
photo.html
<ion-header>
<ion-navbar>
<ion-title>photo</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<ion-grid>
<ion-item *ngFor="let item of items">
<ion-row align-items-stretch>
<ion-col col-12 col-md-6 align-self-stretch align-self-center
approxItemHeight="457px">
<ion-card class="card">
<img src="http://xxxxxx.com/imgshare/{{item.img}}" height="200"
width="200">
<button ion-button color="lightText"
(click)="share(item)">share</button>
</ion-card>
</ion-col>
</ion-row>
</ion-item>
</ion-grid>
</ion-content>
照片.ts
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { HttpClient } from '@angular/common/http';
import { SocialSharing } from '@ionic-native/social-sharing';
@IonicPage()
@Component({
selector: 'page-photo',
templateUrl: 'photo.html',
})
export class PhotoPage {
public items : Array<any> = [ ];
constructor(public navCtrl: NavController, public navParams: NavParams,
public http: HttpClient, private socialSharing: SocialSharing) {
}
ionViewDidLoad() {
console.log('ionViewDidLoad PhotoPage');
}
ionViewWillEnter() : void
{
this.load();
}
load() : void
{
this.http
.get('http://xxxx.com/imgshare/retrieve.php')
.subscribe((data : any) =>
{
console.dir(data);
this.items = data;
console.log(this.items[0].img);
},
(error : any) =>
{
console.dir(error);
});
}
}
【问题讨论】:
-
我已经从 db 中检索了所有图像。现在用户需要将特定图像(不是所有图像)分享到他们的 fb、whatsapp、twitter。如何做到这一点? @Utpaul
-
检查我的答案...
-
谢谢你,我解决了这个问题。无论如何你的回答也是正确的@Utpaul
-
欢迎@vignesh。我上周很忙,抱歉回复晚了...
-
好的,不用 pblm 再次感谢@Utpaul
标签: angular ionic-framework ionic3