我一直在读这个:
https://developers.facebook.com/docs/sharing/reference/share-dialog
我需要导入facebook SDK才能使用以下代码:
- FB.ui({
- method: 'share',href: 'https://developers.facebook.com/docs/',},function(response){});
我如何使用Angular 2应用程序导入facebook SDK?
不需要使用facebook sdk我们可以在同一个ts文件中使用窗口位置,如下所示.而且我们也可以为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()
- }
- }
推特:
- popuptweet(){
- let url = 'https://twitter.com/intent/tweet?text='+ this.shareLink;
- let newwindow=window.open(url,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,resizable');
- if (window.focus) {
- newwindow.focus()
- }
- }