I am trying to put the FB button on my single page site built on Angular JS. A similar button should be displayed on the screen (other than index.html) displayed by the controller. But a similar button only appears the first time I load this particular view. The button does not appear if I return after visiting another view. Below is the code that loads the FB SDK into the controller for presentation -
(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 = "//connect.facebook.net/en_US/all.js#xfbml=1"; fjs.parentNode.insertBefore (js, fjs); } (document, script ',' facebook-jssdk '));
index.html has the following code -
<body ng-controller = "mainController">
<div id = "fb-root">
myView.html
<div class = "fb-like" data-href = "mySite.com/{{ProductID}}" data-> layout = "standard" data-action = "like" data-show-faces = "false" data- share = "true">
I tried various methods, such as using FB.XFBML.Parse (), removing the script tag for FB sdk and adding it every time I boot (with the hope that it will work like the first time), tried using directives by putting fb-root div in different views, and now I do not know: |
I feel the problem is loading or updating the SDK when I view the view again, but I'm not sure.
Understand any contribution that will help me move forward and please let me know if you need more information.
Thanks Sam.
angularjs html5 single-page-application facebook-like facebook-social-plugins
Sam
source share