Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Po.st Social Sharing Widget AngularJS integration
<!doctype html>
<html lang="en" data-framework="angularjs">
<head>
<meta charset="utf-8">
<title>AngularJS Po.st widget integration</title>
<script>
window.pwidget_config = {}; // post widget config (optional)
</script>
<!-- Important: init should be lazy -->
<script src="http://i.po.st/static/v3/post-widget.js#publisherKey=yourKey&init=lazy&retina=true"></script>
</head>
<body>
<!-- Your Angular App. For example https://github.com/tastejs/todomvc/tree/master/examples/angularjs-perf -->
<ul>
<li ng-repeat="todo in todos">
<div data-post-widget class="pw-widget" data-size="medium" data-url="{{todo.url}}">
<a class="pw-button-livejournal"></a>
<a class="pw-button-twitter"></a>
<a class="pw-button-linkedin"></a>
</div>
</li>
</ul>
</body>
</html>
todomvc // todomvc — your angular app namespace
.directive('postWidget', ['$timeout', function ($timeout) {
return {
restrict : 'EAC',
link: function ($scope, element, attributes) {
$timeout(function () {
window.post_init();
});
}
};
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment