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