我用ng-repeat遍历用户列表users,用户有类型(type)A,B,C三个类型,当我遍历用户列表时我需要把用户类型为A的记录(tr标签)的背景颜色变成红色或加一个特定的样式,此效果如何实现?
使用ng-style,在scope上写一个函数,传入user,在该函数中写具体的样式。
比如:$scope.changeStyle=function(user){
if(user.type==="A"){
return {backgroundcolor:'red'};
}
}
u为ng-repeat中的单个user.