Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

496
Views
How to implement sharing to facebook/twitter functionality in Angular

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>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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}}&amp;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>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!