First there are few NPM libraries and second none is working with AngularJS ver 8 (when this article was written).
The above problem prompted me look into the possibility of integrating the time tested platforms for Social Share Widget for web.
I needed a library/code that provides me with the flexibility of customizing which Social Media options to allow and also the content that will be shared (and not just the current URL like happens with most libraries)
I chose ShareThis, which provided all the required flexibility.
There might be other ways to integrate this, but I did it in the below way – which was fast to implement and it works.
Added the below to the index.html of the project
<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
<script type="text/javascript">
stLight.options({
publisher:'12345', /* this is the property Id in new panel*/
});
</script>
Next add the following code to the TS file of the page. I added it to ionViewDidEnter
stWidget.addEntry({
"service":"sharethis",
"element":document.getElementById('button_1'), /*the button's id which will trigger the share dialog*/
"url":"http://sharethis.com", /*the URL to share*/
"title":"sharethis", /*Title*/
"type":"large",
"text":"ShareThis" , /*the text to be displayed beside the button in the webapage*/
"image":"http://www.kolkataonweb.com/images/sharethis.png", /*link of the image to be shared*/
"summary":"this is description1" /*the summary text or the description to be shared.*/
});
Add the button to the HTML of the page where the share button to be shown
<span id="button_1"></span> <!-- please not the id is same as that mentioned in the configuration above -->
The normal integration guide on ShareThis website doesn’t have the customization options mentioned. The possible ways to customize the content to be shared has been mentioned here.
Please feel free to suggest optimizations.