Addthis按钮适用于AngularJs

时间:2014-11-25 23:09:41

标签: angularjs addthis

我想在我的angularjs驱动的网页中使用addthis。在AngularJs and AddThis social plugin处回答答案我写了这样的代码:

GFDirectives.directive('addthisToolbox', function() {
   return {
    restrict: 'A',
    transclude: true,
    replace: true,
    template: '<div ng-transclude></div>',
    link: function ($scope, element, attrs) {
        addthis.init();
        // Dynamically init for performance reason
        // Safe for multiple calls, only first call will be processed (loaded css/images, popup injected)
        // http://support.addthis.com/customer/portal/articles/381263-addthis-client-api#configuration-url
       // http://support.addthis.com/customer/portal/articles/381221-optimizing-addthis-performance            addthis.init();
        // Ajax load (bind events)
        // http://support.addthis.com/customer/portal/articles/381263-addthis-client-api#rendering-js-toolbox
        // http://support.addthis.com/customer/portal/questions/548551-help-on-call-back-using-ajax-i-lose-share-buttons
        addthis.toolbox($(element).get());

       }
    }
});

粒子上的代码如下:

                <div class="row">
                    <div class="col-sm-12">
                        <!-- Go to www.addthis.com/dashboard to customize your tools -->
                        <div class="addthis_toolbox addthis_custom_follow ">Follow Us:</div>
                        <script type="text/javascript">var addthis_config = { "data_track_clickback": false, "data_track_addressbar":false };</script>

                    </div>
                </div>

我在index.html上加载addthis js,如:

    <script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5437a02d238db4c8" async="async"></script>

但我仍然需要手动刷新页面才能在我的网站上显示图标。哪有错误,我应该怎么做才能修复它?

0 个答案:

没有答案