$scope.func = function(thisIndex,preIndex){ var thisIndexDataName = $scope.dataList[thisIndex].dataName;//当前这"/> $scope.func = function(thisIndex,preIndex){ var thisIndexDataName = $scope.dataList[thisIndex].dataName;//当前这">
Home >Web Front-end >JS Tutorial >Angular $index gets the previous data of ng-repeat
<div ng-repeat=<span style="color: #800000">"</span><span style="color: #800000">item in dataList</span><span style="color: #800000">"</span> ng-click=<span style="color: #800000">"</span><span style="color: #800000">func($index,$index-1)</span><span style="color: #800000">"</span>></div>
$scope.func =<span style="color: #000000"> function(thisIndex,preIndex){ </span><span style="color: #0000ff">var</span> thisIndexDataName = $scope.dataList[thisIndex].dataName;<span style="color: #008000">//</span><span style="color: #008000">当前这条数据对应dataName</span> <span style="color: #0000ff">var</span> preIndexDataName = $scope.dataList[preIndex].dataName;<span style="color: #008000">//</span><span style="color: #008000">上一条数据里对应的dataName</span> }
The above is the detailed content of Angular $index gets the previous data of ng-repeat. For more information, please follow other related articles on the PHP Chinese website!