I am trying to have a fb/twitter share functionality in my angular app, but can't get my head around this.
I read this documentation: https://developers.facebook.com/docs/sharing/reference/share-dialog#jssdk
But then I had the same questions in my head like the author of this SO post: Using Facebook SDK in Angular 2
Yet I don't see any working answer.
So I just wanted to make any working button to start from there and used code from this example: https://developers.facebook.com/docs/plugins/share-button/#example
But I can't even see the button. Can some give me a hint where to start? I don't even know what to ask. I thought sharing functionality should be easy
my index.html:
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta property="og:url" content="http://anything/index.html" />
<meta property="og:type" content="website" />
<meta property="og:title" content="Your Website Title" />
<meta property="og:description" content="Your description" />
<meta property="og:image" content="https://www.your-domain.com/path/image.jpg" />
</head>
<body>
<div id="fb-root"></div>
<script>
(function (d, s, id) {
var js,
fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s);
js.id = id;
js.src = 'https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v3.0';
fjs.parentNode.insertBefore(js, fjs);
})(document, 'script', 'facebook-jssdk');
</script>
myComponent.component.ts:
<div
class="fb-share-button"
data-href="http://anything/index.html"
data-layout="button_count">SHARE!!</div>
Try this once
To Share On Facebook -
websiteUrl = 'The URL you want to share';
<button type="button" data-href="websiteUrl"><a target="_blank" href="https://www.facebook.com/sharer/sharer.php?u={{websiteUrl}}&src=sdkpreparse">Facebook</a></button>
To Share On Twitter -
<button><a href="https://twitter.com/intent/tweet?text=text goes here {{websiteUrl}}&hashtags=hashtag1,hashtag2" target="_blank">Twitter</a>
</button>
OR
<button><a href="http://twitter.com/share?text=text goes here&url={{websiteUrl}}&hashtags=hashtag1,hashtag2,hashtag3" target="_blank">Twitter</a>
</button>