AngularJs and AddThis social plugin

后端 未结 6 1686
时光说笑
时光说笑 2020-12-10 06:37

I\'m trying to use the AddThis javascript Social plugin in an AngularJS App, but It does not updates the addthis plugin icons when I load a partial with ng-view. If I refres

6条回答
  •  半阙折子戏
    2020-12-10 07:38

    Wanted to add an additional point to the answer by atonpinchuk. An issue we had in our app was that we had the addthis buttons on various pages and wanted the url and title to vary depending on the page. We have a service that updates the meta tags but because addthis is initiated with the script in our main template, addthis did not pick up on our changed meta tags.

    Our solution was to use the sharing configuration in our directive as noted here: http://support.addthis.com/customer/portal/articles/381263-addthis-client-api#configuration-sharing

    This way addthis picks up the right url and titles. Of course if you want to fully mimick the social sharing features of a non-client side webiste, this is only half the battle. You would need to also write your own service to update tags in the head. Then you need to use phantomJS to create static versions of your site and redirect google, facebook, and other crawlers to it.


    An issue we are having is that the buttons don't render in IE8 for some reason. Haven't figured out a solution yet. The weird thing is that it works if you call it addthis.init() in a script tag via the HTML but this won't work for an SPA. Also addthis.init() is available (ie !!addthis.init() == true in the directive so I am not sure what is wrong with it.

提交回复
热议问题