AngularJS - How to access to the next item from a ng-repeat in the controller -
i'd access parameters of next item on screen when clicking on button.
i use ng-repeat in html file:
<li ng-repeat="item in items | filter:query" ng-show="isselected($index)"> <a href="" ng-click="itemnext()"><img src="xxx.jpg" /></a> </li>
and index in controller loop:
$scope.itemnext = function () { $scope._index = ($scope._index < $scope.nbitems - 1) ? ++$scope._index : 0; $scope.functiontocallwithnextitem(nextitem.param1); };
a simple $scope.items[$scope._index].param1
instead of nextitem.param1
wouldn't work data filtered $index+1
$scope.items
isn't one.
any idea ?
you can assign filtered data variable:
<li ng-repeat="item in (filtereditems = (items | filter:query))">
then use $index + 1
next item:
<a ng-click="itemnext(filtereditems[$index + 1])">
Comments
Post a Comment