angularjs - Nested ng-repeat Issue to open list of rows with in the row -
i want open list of items @ time of respective repeated row, here plunker http://embed.plnkr.co/ombl2czm9frbeviequyd/ please me out.
here object:
$scope.names=[ {no:'1', name:'jani', country:'norway', cities:[{city:'a1'},city:'a2'},{city: 'a3'}]}, {no:'2', name:'hege',country:'sweden', cities:[{city:'b1'},{city:'b2'}, {city: 'b3'}]}, {no:'3', name:'kai',country:'denmark', cities:[{city:'c1'},{city:'c2'}, {city: 'c3'}]}];
here html :
<table> <tbody ng-repeat="name in names"> <tr > <td> {{name.no}} </td> <td> {{name.name}} </td> <td>{{name.country}}</td> <td> <button data-ng-click="isopenpayablepayments[$index] = !isopenpayablepayments[$index]; togglepayablepayments(name.no, $index)" >paid</button> </td> </tr> <tr data-ng-show="isopenpayablepayments[$index]"> <td> <table> <thead> <tr> <th>city</th> </tr> </thead> <tbody> <tr data-ng-repeat="city in cities"> <td>{{city.city}}</td> </tr> </tbody> </table> </td> </tr> </tbody> </table>
call on button click within repeat
var getcities = function (no) { (i = 0; <= $scope.names.length; i++) { if (no === $scope.names[i].no) { console.log($scope.names[i].cities); return $scope.names[i].cities; } }; }; $scope.togglepayablepayments = function (no, index) { $scope.cities = getcities(no); };
i want open nested list respective row. plunkr explains issue.
the problem isn't explained see when open 2nd tree items of tree same. no need of $scope.cities, it's source of problem.
i changed 2nd ng-repeat :
<tr data-ng-repeat="city in cities"> <td>{{city.city}}</td> </tr>
to :
<tr data-ng-repeat="city in name.cities"> <td>{{city.city}}</td> </tr>
Comments
Post a Comment