简体   繁体   English

放置在自定义指令中的ui-codemirror失败,没有错误

[英]ui-codemirror placed within custom directives fails without an error

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 . 我试图从代码镜像角度库使用ui-codemirror角度指令,用例是我必须将它放在自定义指令中。

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 . 但是,当我将它放在自定义指令之外时,它按预期工作。

I am attaching the fiddle code for this http://plnkr.co/edit/NVFuumrGq2FJ8d8EC8Xn?p=preview . 我附上了这个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 . 如果它是一个bug,我们无法得出结论。请指导我。

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

I posted the same as an issue in the code mirror git hub repo . 我在代码镜像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 请参阅: https//github.com/angular-ui/ui-codemirror/issues/36#issuecomment-31925751

Here you go I've fixed it for you: 在这里,我为你修好了:

This is not a bug with code mirror or a bug with AngularJS. 这不是代码镜像的错误或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. 由于具有isolite范围的已编译指令中存在的1.20子节点的释放不再继承新范围,因为它们已经被分配给父范围(我知道这是令人困惑的)但在这种情况下,您需要转换现有的使用指令中的链接器函数代码镜像内容。

Here you go: http://plnkr.co/edit/MaIpdJsPE6qpYqR8BJtQ?p=preview 你去: http : //plnkr.co/edit/MaIpdJsPE6qpYqR8BJtQ?p=preview

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM