如何在角度js上显示插件注释fb?

时间:2016-03-05 05:29:37

标签: angularjs facebook plugins comments

我是角色的新手,我在我的角度网页应用上显示插件评论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 ...我需要帮助谢谢

====================

解决easyfb

0 个答案:

没有答案