AngularJs指令模板与NG-transclude不能编译 [英] AngularJs Directive Template with ng-transclude cannot be compiled

查看:78
本文介绍了AngularJs指令模板与NG-transclude不能编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建两个指令。第一个指令等追加predefined角度指令(NG-点击纳克级)的元素,然后编译它,使他们的工作。

I am trying to create two directives. The first directive appends other predefined angular directives (ng-click and ng-class) to the element and then compiles it so that they work.

的第二个指令替换的元件为包含第一指令的模板。我用NG-transclude到模板携带元素的内容。

The second directive replaces an element for a template which contains the first directive. I use ng-transclude to carry the element's contents over to the template.

的问题是,一旦被加到从指令2中的模板的第一个指令试图编译并抛出摇晃:

The problem is that once the template from directive 2 is added the first directive tries to compile and throws a wobbly:

类型错误:未定义是不是一个函数

"TypeError: undefined is not a function"

指令1工作正常。我创建了一个普拉克来证明这一点: http://plnkr.co/edit/RdtjIy5XKOsqvh5VnwMr

Directive 1 works fine when ng-transclude is not present in the template. I have created a Plunk to demonstrate this: http://plnkr.co/edit/RdtjIy5XKOsqvh5VnwMr

有没有人能提供帮助,并指出我要去的地方错了?

Is anyone able to help out and point out where I am going wrong?

谢谢,
山姆

推荐答案

在进一步的试验和错误我已经找到了解决而据我所知,没有任何副作用。

After further trial and error I have found a fix and as far as I can tell, there are no side-effects.

我只是从第二个指令中删除NG-transclude属性。我在这里有一个更新的普拉克: http://plnkr.co/edit/9QXkqzzyUy9VvMYC6fO6

I simply remove the ng-transclude attribute from within the second directive. I have an updated Plunk here: http://plnkr.co/edit/9QXkqzzyUy9VvMYC6fO6

这篇关于AngularJs指令模板与NG-transclude不能编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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