我正在使用has-dropdown指令,我尝试在顶栏生成递归导航链接,但我的 Angular 抛出错误:
Error: [$compile:multidir] Multiple directives [ngInclude, hasDropdown] asking for transclusion on: <li ng-repeat="data in pageList" ng-include="'tree.html'" ng-if="!data.node.length == 0" has-dropdown="">
这是我的用法:
<ul class="right">
<li ng-repeat="data in pageList" ng-include="'tree.html'" has-dropdown>
</li>
</ul>
<script type="text/ng-template" id="tree.html">
<a>[[data.name]] [[data.parent]]</a>
<ul top-bar-dropdown>
<li ng-repeat="data in data.node" ng-include="'tree.html'"></li>
</ul>
</script>
我知道我不能在一个元素中使用 ng-include 和 has-dropdown,但我需要做一些事情才能使其正常工作,您能给我一个提示来理解我的问题以解决它吗?
最佳答案
这是演示:http://plnkr.co/edit/Rxxt3ufG26PAM7GYoNOJ?p=preview 具有简化的数据限制。
以分层方式重新排列指令会有所帮助。这样你就可以:
ng-repeat > ng-include > has-dropdown
<ul class="right">
<div ng-repeat="data in pageList" ng-include="'tree.html'">
</div>
</ul>
<script type="text/ng-template" id="tree.html">
<li has-dropdown>
<a>{{data.name}}</a>
<ul top-bar-dropdown>
<li ng-repeat="submenu in data.node" ng-include="'simple.html'"></li>
</ul>
</li>
</script>
<script type="text/ng-template" id="simple.html">
//
</script>
关于javascript - Angular-foundation 多个指令要求嵌入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35534443/