<style>
.selected{background-color:
lightgreen;}
</style>
<body>
<table
ng-controller="restaurantTableController">
<tr
ng-class="{selected:$index==selectedRow}" ng-repeat=‘restaurant in directory‘
ng-click="selectRestaurant($index)">
<td>{{restaurant.name}}</td>
<td>{{restaurant.cuisine}}</td>
</tr>
</table>
</body>
<script>
var
app=angular.module("myApp",[]);
app.controller("restaurantTableController",function($scope){
$scope.directory=[{name:‘hongshu‘,cuisine:‘bbq‘},{name:‘gee‘,cuisine:‘slad‘},{name:‘sbnm‘,cuisine:‘dffffrew‘}];
$scope.selectRestaurant=function(row){
$scope.selectedRow=row;
}
});
</script>
原文:http://www.cnblogs.com/java-php/p/3693007.html