相关疑难解决方法(0)

在嵌套的ng-repeat中传递2 $ index值

所以我有一个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

angularjs angularjs-ng-repeat

316
推荐指数
4
解决办法
18万
查看次数

如何将ng-repeat放入ng-repeat中n次

我有一个具有嵌套节点的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)

html javascript angularjs

7
推荐指数
1
解决办法
673
查看次数

标签 统计

angularjs ×2

angularjs-ng-repeat ×1

html ×1

javascript ×1