LoginSignup
0
0

More than 5 years have passed since last update.

ng-repeat中の特定の要素に別の要素を挿入

Last updated at Posted at 2015-05-30

$indexでrepeat中のアイテムのインデックスが取得できる。
けど、こうやって変数にアクセスしたほうがわかりやすい。(コメントでのご指摘ありがとうございます!!)

<div ng-repeat="item in items" ng-click="addFuga($index)">
    <div> {{ item.hoge }} </div>
    <div ng-show="item.fuga"> {{ item.fuga }} </div>
</div>

じゃなくって、↓のように。

<div ng-repeat="item in items" ng-click="addFuga(item)">
$scope.addFuga = function(item){
    item.fuga = 'Someting insert you want'
}
0
0
3

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
0
0