LoginSignup
7
6

More than 5 years have passed since last update.

子のng-repeatで親のng-repeatのindexを参照したい

Posted at

まんまなのですが日本語でメモ

$parent.$index って方法もあるみたいですが、複雑になってくると階層とか一々数えてられないので、明示的に以下のように設定する方法が一番良いと思いました。

<div ng-repeat="(fIndex, f) in foos">
  <div>
    <div ng-repeat="b in foos.bars">
      <a ng-click="addSomething(fIndex)">Add Something</a>
    </div>
  </div>
</div>

参考
http://stackoverflow.com/questions/14807258/access-index-of-the-parent-ng-repeat-from-child-ng-repeat#answer-18914958

7
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
6