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中文网
Release: 2017-06-17 17:27:29
Original
1501 people have browsed it
<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>
Copy after login
$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>
}
Copy after login

 

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!

Related labels:
source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template