prismJS没有与angularJS工厂合作

时间:2016-02-20 19:22:37

标签: angularjs

我有一个项目,其中包含一些代码。所以我想用prismJS代码荧光笔。我为棱镜做了一个角度指令,当我编写像

这样的代码时,它工作正常
<pre><code ng-prism class="language-css">p{color:red;}</code></pre>

但是我有一个工厂可能包含这一行作为字符串,我想渲染这个字符串。 我的工厂喜欢 -

    .factory('myFactory',function(){
        var fact ={};
        var code = [
                {      
                  text:'<pre><code ng-prism class="language-css">p{color:red;}</code></pre>'
                 }
           ]
       fact.getCode = function(){
           return code;
       }
return fact;
    })

我创建的指令是 -

.directive('ngPrism', [function() {
    return {
        restrict: 'A',
        link: function($scope, element, attrs) {
            element.ready(function() {
                Prism.highlightElement(element[0]);
            });
        }
    }
  }])

现在我想用使用棱镜的代码突出显示文本代码。但我不能。

0 个答案:

没有答案
相关问题