0

I tried to integrate facebook share and like button into my single page application with angularjs. They have mentioned that by putting those codes inside the body tag, it will work fine and it works fine when I refresh the page manually. Therefore I searched a bit and tried angularjs-facebook-sdk. But the problem is still the the same, it works only when the page is manually refreshed.

Here is the code part which I used in the config part of it.

.config(function facebookConfig (facebookConfigProvider) {
    facebookConfigProvider.setAppId(285290671625269);
    facebookConfigProvider.setLanguage('en-US');
    facebookConfigProvider.setDebug(true);
    facebookConfigProvider.autoInit(true);
    facebookConfigProvider.setOptions({
        status: true
    });
})

and here is the html part that I have used on the page.

<afb:like href="http://www.linkedin.com/in/pranjutgogoi" layout="button_count" action="like" show-faces="true" share="false" on-edge-created="onEdgeCreated(url);" on-edge-removed="onEdgeRemoved(url);"></afb:like>

If possible please tell what is the problem, and how do I solve it?

Pranjut
  • 1,747
  • 5
  • 18
  • 31

1 Answers1

0

I was having the same issue, and the fix that worked for me was simply adding:

        scope.$watch('href',function(){
            facebookService.ready.then(function () {
                FB.XFBML.parse();
            });
        })

to one of the Facebook directives ('share', in my case), since FB.XBML.parse() should parse all Facebook elements in the scope, I suppose.

buruno
  • 1