$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

Angular $index gets the previous data of ng-repeat

PHP中文网
PHP中文网Original
2017-06-17 17:27:291499browse
<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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn