Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
change css3
<!doctype html>
<html lang="en" ng-app>
<head>
<meta charset="UTF-8">
<title>test</title>
<style>
.selected {
background-color: lightgreen;
}
</style>
</head>
<body>
<table ng-controller='tableController'>
<tr ng-repeat='item in list'
ng-click='selectItem($index)'
ng-class='{selected: $index == selectedRow}'>
<td>{{item.name}}</td>
<td>{{item.age}}</td>
</tr>
</table>
<script type="text/javascript" src="angular.min.js"></script>
<script type="text/javascript" src="main.js"></script>
</body>
</html>
function tableController($scope) {
$scope.list = [
{name: 'houyao', age: 12},
{name: 'liurui', age: 22},
{name: 'daxue', age: 42}
];
$scope.selectItem = function(row) {
$scope.selectedRow = row;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.