我想知道在下面的示例中如何将背景颜色添加到新添加的行中。添加新行时,滚动条会向下滚动,但如何通过向该行添加背景色来突出显示它。任何帮助都会很棒。这是 fiddle - http://jsfiddle.net/cpfx07qq/
html -
<div ng-app="myApp" ng-controller="MyCtrl">
<button ng-click="add()" scroll-bottom="bottom">Add</button>
<ul id="bottom">
<li ng-repeat="item in list">{{item}}</li>
</ul>
</div>
最佳答案
试试这个:
<div ng-app="myApp" ng-controller="MyCtrl">
<button ng-click="add()" scroll-bottom="bottom">Add</button>
<ul id="bottom">
<li ng-repeat="item in list" ng-class="{last: $last && isNew }">{{item}}</li>
</ul>
</div>
在 controller
中:
function MyCtrl($scope) {
$scope.isNew = false;
$scope.list = ["item 1", "item 2", "item 3", "item 4", "item 5"];
$scope.add = function() {
$scope.isNew = true;
$scope.list.push("new item");
}
}
在 css
中:
.last {
background-color: red;
}
关于javascript - 如何为新添加的行添加背景颜色angularjs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41529781/