选中行高亮

<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>

posted @ 2014-04-26 22:42  粉条  Views(289)  Comments(0)    收藏  举报