A Pen by CarterTsai on CodePen.
Created
March 27, 2014 16:29
-
-
Save CarterTsai/9811701 to your computer and use it in GitHub Desktop.
A Pen by CarterTsai.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script> | |
<div ng-app="fbtest" ng-controller="FBCtrl"> | |
<fb-comment href="http://example.com/comments" | |
numposts="1" | |
colorscheme="light" | |
order="" | |
width="720"> | |
</fb-comment> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ref: https://developers.facebook.com/docs/plugins/comments/ | |
angular.module('fb.comment', []) | |
.directive('fbComment', function() { | |
function link(scope, element, attrs) { | |
(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/zh_TW/all.js#xfbml=1&appId=638664449487662"; | |
fjs.parentNode.insertBefore(js, fjs); | |
}(document, 'script', 'facebook-jssdk')); | |
} | |
return { | |
link: link, | |
// matches element | |
restrict: 'E', | |
// Text Binding (Prefix: @) | |
// One-way Binding (Prefix: &) | |
// Two-way Binding (Prefix: =) | |
scope: { | |
href: '@href', | |
numpost : '@numpost', | |
colorscheme: '@colorscheme', | |
order: '@order', | |
width: '@width' | |
}, | |
template: '<div class="fb-comments" '+ | |
'data-href="{{href}}" '+ | |
'data-numposts="{{numpost}}" '+ | |
'data-colorscheme="{{colorscheme}}" '+ | |
'data-order-by="{{order}}" '+ | |
'data-width="{{width}}"> '+ | |
'</div>', | |
}; | |
}); | |
var app = angular.module('fbtest', ['fb.comment']); | |
function FBCtrl($scope) { | |
$scope.test = "testing"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment