我是角色的新手,我在我的角度网页应用上显示插件评论fb时遇到了一些问题。
我遵循本教程:jsfiddle
示例代码:
// preview.directive.js :
'use strict';
window.FB = {
XFBML: {
parse: function (elem) {
var pre = document.createElement('pre');
pre.textContent = elem.innerHTML;
document.getElementById('fb-comment-box').innerHTML =
pre.outerHTML;
}
}
};
angular.module('kulinerLezatkuApp')
.directive('myFbCommentBox', function () {
function createHTML(href, numposts, colorscheme) {
return '<div class="fb-comments" ' +
'data-href="' + href + '" ' +
'data-numposts="' + numposts + '" ' +
'data-colorsheme="' + colorscheme + '">' +
'</div>';
}
return {
restrict: 'A',
scope: {},
link: function postLink(scope, elem, attrs) {
attrs.$observe('pageHref', function (newValue) {
var href = newValue;
var numposts = attrs.numposts || 5;
var colorscheme = attrs.colorscheme || 'light';
elem.html(createHTML(href, numposts, colorscheme));
FB.XFBML.parse(elem[0]);
});
}
};
});
// preview.html
<div id="fb-comment-box" my-fb-comment-box=""
page-href="http://localhost:9000/items/{{main.myParams._id}}/preview"
numposts="5"
colorsheme="light">
但在我的页面上只显示文字,而不是HTML ...我需要帮助谢谢
====================