在Angular 2中使用Facebook SDK

前端之家收集整理的这篇文章主要介绍了在Angular 2中使用Facebook SDK前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我一直在读这个: https://developers.facebook.com/docs/sharing/reference/share-dialog

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

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

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

不需要使用facebook sdk我们可以在同一个ts文件中使用窗口位置,如下所示.而且我们也可以为twitter linkedin这样的社交媒体做同样的事情.

Facebook:

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

推特:

  1. popuptweet(){
  2. let url = 'https://twitter.com/intent/tweet?text='+ this.shareLink;
  3. let newwindow=window.open(url,resizable');
  4. if (window.focus) {
  5. newwindow.focus()
  6. }}

Linkedin:

  1. popuplinkedin(){
  2. let url ='https://www.linkedin.com/shareArticle?mini=true&url='+this.shareLink;
  3. let newwindow=window.open(url,resizable');
  4. if (window.focus) {
  5. newwindow.focus()
  6. }
  7. }

猜你在找的Angularjs相关文章