-
-
Save kosso/5dfd48ef1dd748c7c11d4ecee5512ef4 to your computer and use it in GitHub Desktop.
Angular directive to embed Facebook public post
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
(function () { | |
'use strict'; | |
/** | |
* @desc Direictive to embed facebook post | |
* @example <fb-post-preview data-href="vm.postUrl"></fb-post-preview> | |
*/ | |
angular | |
.module('fbDirective') | |
.directive('fbPostPreview', fbPostPreview); | |
/* @ngInject */ | |
function fbPostPreview($timeout) { | |
var directive = { | |
link: link, | |
template: '<div class="fb-post" data-href="{{href}}"></div>', | |
restrict: 'EA', | |
scope: { | |
href: '=href' | |
} | |
}; | |
return directive; | |
function link(scope, element, attrs) { | |
$timeout(function() { | |
if (FB) { | |
FB.XFBML.parse(element[0]); | |
} | |
}); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment