在angularjs指令中链接指令 [英] Chaining directive within directive in angularjs
问题描述
我希望创造类似下面的使用自定义指令。我抽到了分类部分,但不是面包屑的一部分。
I wished to create something like the following using custom directive. I am able to get the "Categories" section, but not the "breadcrumb" part.
使用在痕迹指令纳克重复,不能正常工作。
Using ng-repeat in the breadcrumb directive, does not work.
我可以观察到痕迹,但在里元素的 UL 不追加到的 UL
I can observe the ul of the breadcrumb but the li element are not appended to the ul.
以下是我的小提琴,由于某种原因,code工作在我的身边上的jsfiddle不起作用。但我已经把它只是给一些想法。
Following is my fiddle and for some reason the code works on my side does not work on jsfiddle. But I have placed it just to give some idea.
<div ng-controller="sampleCtrl">
<tree src="categories"></tree>
</div>
树指令调用点击分支。
在点击分公司所谓的面包屑
Tree directive calls branch on click. Branch on click calls "breadcrumb"
纳克重复并不在这里工作:
ng-repeat does not work here:
template: '<ul><breadcrumbnode ng-repeat="node in breadcrumbs" src="node"></breadcrumbnode></ul>'
这是从来没有所谓的:
template: '<li><a>{{ node }}</a></li>',
后市展望:在分支节点的点击床垫(例如,在小提琴),我希望知道在格观察名单带班面包屑过滤器
Expectation: On click of the branch node "Mattresses" (for example in fiddle), I expect to know observe a list under div with class "bread-crumb-filter".
这可能是什么指令的可能原因不工作的任何指针。
Any pointers on what could be the possible cause of the directive not working.
在此先感谢!
推荐答案
在的jsfiddle不需要第三个指令。我迷上了分支节点的单击事件,一个服务,然后链接类别的内容到rootscope(这是我的要求)。我会看到我的情况下可以用工作实现调整小提琴一旦我得到了一段时间。
The third directive is not required in jsfiddle. I hooked a service on "click" event of the "branch" node and then linked the category content to the rootscope (which was my requirement). I will see in case I can tweak the fiddle with a working implementation once I get some time.
这篇关于在angularjs指令中链接指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!