<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> }
以上是angular $index获取ng-repeat的上一条数据的详细内容。更多信息请关注PHP中文网其他相关文章!