在Angular 2中使用Facebook SDK [英] Using Facebook SDK in Angular 2

查看:160
本文介绍了在Angular 2中使用Facebook SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在阅读以下内容: https://developers.facebook.com/docs/sharing/参考/共享对话框

I've been reading this: https://developers.facebook.com/docs/sharing/reference/share-dialog

并且我需要导入facebook SDK才能使用以下代码:

and I need to import the facebook SDK in order to use the following code:

FB.ui({
  method: 'share',
  href: 'https://developers.facebook.com/docs/',
}, function(response){});

如何使用Angular 2应用程序导入facebook SDK?

How I Can import the facebook SDK using Angular 2 app?

推荐答案

无需使用facebook sdk,我们可以在同一ts文件中使用窗口位置,如下所示.而且我们也可以对任何社交媒体(例如twitterlinkedin)进行相同的操作.

No need to use facebook sdk we can use window location in same ts file as like below. And also we can do it same for any social media like twitter linkedin.

Facebook:

popupfacebook() {
    let url = 'http://www.facebook.com/sharer.php?u='+ this.shareLink;
       let newwindow=window.open(url,'name','height=500,width=520,top=200,left=300,resizable');
  if (window.focus) {
      newwindow.focus()
  } 
}

Twitter:

popuptweet(){
       let url = 'https://twitter.com/intent/tweet?text='+ this.shareLink;
       let newwindow=window.open(url,'name','height=500,width=520,top=200,left=300,resizable');
  if (window.focus) {
      newwindow.focus()
}}

Linkedin:

popuplinkedin(){
      let url ='https://www.linkedin.com/shareArticle?mini=true&url='+this.shareLink;
       let newwindow=window.open(url,'name','height=500,width=520,top=200,left=300,resizable');
  if (window.focus) {
      newwindow.focus()
  }
}

这篇关于在Angular 2中使用Facebook SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆