Create share button on Linkedin

3

I'm developing a Web Project and in this project it contains the button to share in Linkedin (custom).

I've worked with sharing Facebook and Twitter and so far it's working fine, but I've never used Linkedin sharing, have anyone used it and can you help me?

Follow the code below:

Share Facebook:

Html:

<a href="" ng-click="vm.facebook(baseurl + 'conteudo/' + conteudo.slug)">
    <div class="img-circle compartilhar_icones">
        <i class="fa fa-facebook" aria-hidden="true"></i>
   </div>
</a>

JS:

vm.facebook = function (s) {
        event.preventDefault();
        window.open('https://www.facebook.com/sharer/sharer.php?u=' + s, '/&display=popup&ref=plugin', 'Pagina', 'STATUS=NO, TOOLBAR=NO, LOCATION=NO, DIRECTORIES=NO, RESISABLE=NO, SCROLLBARS=YES, TOP=10, LEFT=10, WIDTH=770, HEIGHT=200');
    };

This code is working, it follows the code I'm using for Linkedin, but it is not working:

Html:

<a href="" ng-click="vm.linkedin(baseurl + 'conteudo/' + conteudo.slug, conteudo.nome)">          
  <div class="img-circle compartilhar_icones terceiro">
        <i class="fa fa-linkedin icone_linkedin" aria-hidden="true"></i>
   </div>
</a>

JS:

vm.linkedin = function (s, a){
        event.preventDefault();
        window.open('http://www.linkedin.com/shareArticle?mini=true&amp;url=' + s +';title=' + a +'', '', '550', '510', 'yes');
  };
    
asked by anonymous 05.08.2016 / 20:01

1 answer

2

Probably how angular it is should change something, however one of the errors it gave me was:

  

... event not defined ...

But angled this may not happen.

I do not know if it will help, but here it is in the 'native' way:

<a href="#" onclick="linkedin(event, 'yo.com', 'meu nome');return false;">          
  <div class="img-circle compartilhar_icones terceiro">
        <i class="fa fa-linkedin icone_linkedin" aria-hidden="true">LINKDIN</i>
   </div>
</a>

JS:

linkedin = function (event, s, a){
    event.preventDefault();
    window.open('https://www.linkedin.com/cws/share?url=' +s+ '?name=' +a, 'newwindow', 'width=680, height=450');
};

EXAMPLE functional in jsfiddle

    
05.08.2016 / 20:19