我正在使用ng-repeat,但是如果它們滿足某些條件,我想修改迭代。我的問題是,獲得那些應該修改的特定迭代的最佳方式是什麼?
現在看來,我已經使用:nth-child選擇器工作,但我想知道是否有更有角度的方式來使用$index
或其他更有角度的方式來執行此操作?
HTML摘錄:
<div class="line_row" ng-repeat="x in program">
{{x.current_state}
</div>
JS代碼片段:
for (j = 0; j < $scope.program.length; j++) {
if ($scope.reader_location[j] == someCondition) {
// this is the line that I'm interested in replacing.
$(".line_row:nth-child("+(j+1)+")").css("background-color","red")
}
}
嘿,你能幫我在這裏,.. http://stackoverflow.com/q/33997547/4044949 –