编译指令AngularJS内部指令

编程入门 行业动态 更新时间:2024-10-27 09:33:25
本文介绍了编译指令AngularJS内部指令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图使用 HighlightJS 上&LT指令; pre方式>由块href=\"github/btford/angular-markdown-directive\" rel=\"nofollow\">降价指令

I am trying to use a HighlightJS directive on <pre> blocks rendered by a Markdown directive.

的下面是一个plunker重现问题:的结果 plnkr.co/edit/qZlMkjNZglV453caNphy?p=$p$pview

在这个例子:

<btf-markdown> #Markdown directive <pre hljs> angular.forEach($scope.items,function(item){ console.log(item); }); </pre> </btf-markdown>

我期望&LT; pre&GT; 块的话,被 hljs 解析但没有。

I would expect the <pre> block to get parsed by hljs but does not.

我必须手动调用内部指令的编写?

Do I have to manually invoke the compilation of the inner directive?

推荐答案

在 btford.markdown 你的 element.html(HTML); 是覆盖 hljs

而不是:

var html = converter.makeHtml(element.text()); element.html(html);

我想你会preFER:

I think you'd prefer:

var html = converter.makeHtml(element.html()); element.html(html);

开关 element.text()与 element.html()

所以你转换整个HTML元素(包括你的 hljs - 这是不是在 element.text())。

So you're converting the whole html element (including your hljs - which isn't in element.text()).

下面是更新plunker: plnkr.co/edit/cURJ1QRfJRheOxTvYc1p? p = preVIEW

Here's the updated plunker: plnkr.co/edit/cURJ1QRfJRheOxTvYc1p?p=preview

更多推荐

编译指令AngularJS内部指令

本文发布于:2023-11-13 11:56:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1584292.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:指令   AngularJS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!