Using Facebook SDK in Angular 2

TheUnreal picture TheUnreal · Jul 28, 2016 · Viewed 7.7k times · Source

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

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){});

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

Answer

Rajesh Kumar Kanumetta picture Rajesh Kumar Kanumetta · Mar 29, 2018

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()
  }
}