Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

499
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda