Skip to content

Instantly share code, notes, and snippets.

@alcance
Forked from laurentiuc/addThis-directives.js
Last active August 29, 2015 14:15
Show Gist options
  • Save alcance/d0e17bea7bc8dc6ac6ff to your computer and use it in GitHub Desktop.
Save alcance/d0e17bea7bc8dc6ac6ff to your computer and use it in GitHub Desktop.
angular.module('myApp').directive('addthisToolbox', ['$timeout', function($timeout) {
return {
restrict : 'A',
transclude : true,
replace : true,
template : '<div ng-transclude></div>',
link : function($scope, element, attrs) {
$timeout(function () {
addthis.init();
addthis.toolbox($(element).get(), {}, {
url: attrs.url,
title : "My Awesome Blog",
description : 'Checkout this awesome post on blog.me'
});
});
}
};
}]);
<html>
<head>
<script type="text/javascript">
var addthis_config = {"data_track_addressbar":true};
</script>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid="></script>
</head>
<body>
<!-- html code -->
<div class="blog-posts" data-ng-repeat="post in posts">
<!-- AddThis Button BEGIN -->
<div data-addthis-toolbox data-url="http://blog.me/{{post.link}}" id="bp-{{post.id}}"
class="addthis_toolbox addthis_default_style addthis_16x16_style">
<a class="addthis_button_facebook"></a>
<a class="addthis_button_twitter"></a>
<a class="addthis_button_google_plusone_share"></a>
<a class="addthis_button_email"></a>
</div>
<!-- AddThis Button END -->
</div>
<!-- more html code -->
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment