所以我有一个ng-repeat嵌套在另一个ng-repeat中,以便构建一个导航菜单.在<li>内部ng-repeat循环中的每一个上,我设置了一个ng-click,它通过传入$ index来调用该菜单项的相关控制器,让应用程序知道我们需要哪一个.但是我还需要从外部ng-repeat传入$ index,以便app知道我们所在的部分以及哪个教程.
<ul ng-repeat="section in sections">
<li class="section_title {{section.active}}" >
{{section.name}}
</li>
<ul>
<li class="tutorial_title {{tutorial.active}}" ng-click="loadFromMenu($index)" ng-repeat="tutorial in section.tutorials">
{{tutorial.name}}
</li>
</ul>
</ul>
Run Code Online (Sandbox Code Playgroud)
这是一个Plunker http://plnkr.co/edit/bJUhI9oGEQIql9tahIJN?p=preview
我有一个具有嵌套节点的JSON对象,可以继续使用任意数量的级别.我需要在点击它的父节点时显示节点的内容.它看起来像这样
"node": [
{
"id": "id of the concept model",
"name": "Curcumin",
"type": "conceptmodel",
"node": [
{
"id": "group1",
"name": "Node 01",
"weight": "70",
"type": "text",
"node": [
{
"id": "group11",
"name": "Node 02",
"weight": "70",
"type": "structure",
"node": []
}
]
}
]
},
{
"id": "id of the concept model",
"name": "Abuse Resistent Technology",
"type": "conceptmodel",
"node": [
{
"id": "group1",
"name": "Category 01",
"weight": "70",
"type": "text",
"node": []
}
]
},
{
"id": "id of the …Run Code Online (Sandbox Code Playgroud)