【问题标题】:Angular Bootstrap Prettyprint directive not being invoked未调用 Angular Bootstrap Prettyprint 指令
【发布时间】:2013-04-04 18:31:53
【问题描述】:

有人有使用 angular-bootstrap-prettify.js 漂亮打印指令的经验吗?我在让它工作时遇到问题。 这是我的示例:http://jsfiddle.net/mjxNV/

<div ng-app>
    <div ng-controller="Ctrl1">
        <pre class="prettyprint linenums">
            <code class="lang-html">
                &lt;div class=&quot;container&quot;&gt;
                    &lt;div class=&quot;left_column&quot;&gt;
                        &lt;span&gt;Small Text&lt;/span&gt;
                    &lt;/div&gt;
                    &lt;div class=&quot;r_ightcolumn2&quot;&gt;
                        &lt;span&gt;Small Text&lt;/span&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
            </code>
        </pre>
    </div>
</div>

我的代码已显示,但它从未经过漂亮打印标记化。我做错了什么?

【问题讨论】:

  • 需要创建模块并注入外部指令作为依赖

标签: angularjs pretty-print


【解决方案1】:

我找到了一个示例并修改为您的示例:

angular.module('app', [])
    .controller('ctrl', function($scope) { });

ap.directive('prettyprint', function() {
    return {
    restrict: 'C',
        link: function postLink(scope, element, attrs) {
            element.html(prettyPrintOne(element.html(),'',true));
        }
    };
});

http://jsfiddle.net/yAv4f/210/

【讨论】:

    猜你喜欢
    • 2017-06-29
    • 2015-01-07
    • 1970-01-01
    • 1970-01-01
    • 2015-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多