放置在自定义指令中的 ui-codemirror 失败且没有错误 [英] ui-codemirror placed within custom directives fails without an error

查看:23
本文介绍了放置在自定义指令中的 ui-codemirror 失败且没有错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 代码中的 ui-codemirror 角度指令镜像角度库,用例是我必须将它放在自定义指令中.

I am trying to use ui-codemirror angular directive from code mirror angular library and the use case is that I have to place it within a custom directive .

但是当我将它放在自定义指令中时,我无法在文本区域中看到代码镜像.事实上,文本区域变得不可编辑.

But when I place it within a custom directive I am unable to see the code mirror in the text area. infact the text area becomes non editable .

但是当我将它放在自定义指令之外时,它会按预期工作.

But when I place it outside the custom directive it works as expected .

我附上了这个http://plnkr.co/edit/NVFuumrGq2FJ8d8EC8Xn?p=预览.我什至没有选择调试,因为甚至没有错误.无法断定这是一个错误.请指导我.

I am attaching the fiddle code for this http://plnkr.co/edit/NVFuumrGq2FJ8d8EC8Xn?p=preview . I have no option to even debug since there is not even an error . Unable to conclude if it is a bug.Please guide me .

最新更新(2014 年 1 月 17 日)-

我在代码镜像 git hub repo 中发布了相同的问题.负责它的人确认这是一个错误,他现在不会修复它.所以也许我们应该尝试解决方法.参见:https://github.com/angular-ui/ui-codemirror/issues/36#issuecomment-31925751

I posted the same as an issue in the code mirror git hub repo . The person working on it confirmed that it is a bug and that he is not going to fix it for now . So may we should try workarounds . see : https://github.com/angular-ui/ui-codemirror/issues/36#issuecomment-31925751

推荐答案

给你,我已经帮你解决了:

Here you go I've fixed it for you:

这不是代码镜像的错误或 AngularJS 的错误.自从 1.20 版本存在于具有 isolite 作用域的已编译指令中的子节点不再继承新作用域,因为它们已经分配给父作用域(我知道这很令人困惑),但在这种情况下,您需要嵌入现有的代码使用指令中的链接器函数镜像内容.

This is not a bug with code mirror or a bug with AngularJS. Since the release of 1.20 child nodes that exists within a compiled directive that has an isolite scope no longer inherit the new scope as they have already be assigned to the parent scope (I know it's confusing) but in this case you needed to transclude the existing code mirror content using the linker function in the directive.

给你:http://plnkr.co/edit/MaIpdJsPE6qpYqR8BJtQ?p=preview

这篇关于放置在自定义指令中的 ui-codemirror 失败且没有错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆