-
Notifications
You must be signed in to change notification settings - Fork 0
/
tables.html
36 lines (32 loc) · 977 Bytes
/
tables.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<!-- left off at page 26//-->
<html ng-app>
<style>
.selected {
background-color:lightgreen;
}
</style>
<body>
<table ng-controller="RestaurantTableController">
<tr ng-repeat="restaurant in directory" ng-click="selectRestaurant($index)" ng-class="{selected: $index == selectedRow}">
<td>{{restaurant.name}}</td>
<td>{{restaurant.cuisine}}</td>
</tr>
</table>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.min.js"></script>
<script type="text/javascript">
function RestaurantTableController ($scope) {
$scope.directory = [
{name: 'the handsome heifer', cusine: 'bbq'},
{name: 'green\'s green greens', cusine: 'salads'},
{name: 'house of fine fish', cusine: 'seafood'}
];
$scope.selectRestaurant = function (row) {
$scope.selectedRow = row;
};
var dereg = $scope.$watch($scope.selectedRow, function (newValue, oldValue, scope) {
console.log('changed');
});
}
</script>
</body>
</html>