Javascript 如何向新添加的行angularjs添加背景色

Javascript 如何向新添加的行angularjs添加背景色,javascript,css,angularjs,html,Javascript,Css,Angularjs,Html,在下面的示例中,我想知道如何将背景颜色添加到新添加的行中。添加新行时,滚动条会向下移动,但是如何通过向行添加背景色来突出显示它。任何帮助都会很好。这是小提琴- html- 添加 {{item} 试试这个: <div ng-app="myApp" ng-controller="MyCtrl"> <button ng-click="add()" scroll-bottom="bottom">Add</button> <ul id="bot

在下面的示例中,我想知道如何将背景颜色添加到新添加的行中。添加新行时,滚动条会向下移动,但是如何通过向行添加背景色来突出显示它。任何帮助都会很好。这是小提琴-

html-
添加
  • {{item}
试试这个:

<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>
css
中:

.last {
   background-color: red;
}
试试这个:

<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>
css
中:

.last {
   background-color: red;
}
var myApp=angular.module('myApp',[]);
myApp.directive(“scrollBottom”,function()){
返回{
链接:功能(范围、元素、属性){
变量$id=$(“#”+attr.scrollbooth);
$(元素)。在(“单击”,函数()上){
$id.scrollTop($id[0].scrollHeight);
});
}
}
});
函数MyCtrl($scope){
$scope.list=[“项目1”、“项目2”、“项目3”、“项目4”、“项目5”];
$scope.add=函数(){
$scope.list.push(“新项目”);
}
}
ul{
高度:150像素;
溢出y:自动;
}
李:最后一个孩子{
背景色:红色;
}

添加
  • {{item}
var myApp=angular.module('myApp',[]);
myApp.directive(“scrollBottom”,function()){
返回{
链接:功能(范围、元素、属性){
变量$id=$(“#”+attr.scrollbooth);
$(元素)。在(“单击”,函数()上){
$id.scrollTop($id[0].scrollHeight);
});
}
}
});
函数MyCtrl($scope){
$scope.list=[“项目1”、“项目2”、“项目3”、“项目4”、“项目5”];
$scope.add=函数(){
$scope.list.push(“新项目”);
}
}
ul{
高度:150像素;
溢出y:自动;
}
李:最后一个孩子{
背景色:红色;
}

添加
  • {{item}
这可能有帮助,这可能有帮助,