Using Facebook SDK in Angular 2

后端 未结 3 1756
别那么骄傲
别那么骄傲 2021-01-04 10:42

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

3条回答
  •  难免孤独
    2021-01-04 10:56

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

提交回复
热议问题