实例代码“Ctrl+/”提示“F11/ESC”全屏 返回 格式化 恢复 运行
x
 
1
<!DOCTYPE html>
2
<html>
3
<style>
4
table, td  {
5
  border: 1px solid grey;
6
  border-collapse: collapse;
7
  padding: 5px;
8
}
9
</style>
10
<script src="https://apps.bdimg.com/libs/angular.js/1.3.9/angular.min.js"></script>
11
<body>
12
13
<div ng-app="myApp" ng-controller="customersCtrl"> 
14
15
<table>
16
  <tr ng-repeat="x in names">
17
    <td ng-if="$odd" style="background-color:#f1f1f1">
18
    {{ x.Name }}</td>
19
    <td ng-if="$even">
20
    {{ x.Name }}</td>
21
    <td ng-if="$odd" style="background-color:#f1f1f1">
22
    {{ x.Country }}</td>
23
    <td ng-if="$even">
24
    {{ x.Country }}</td>
25
  </tr>
26
</table>
27
28
</div>
29
30
<script>
31
var app = angular.module('myApp', []);
32
app.controller('customersCtrl', function($scope, $http) {
33
    $http.get("/static/example/Customers_JSON.php")
34
    .success(function (response) {$scope.names = response.records;});
35
});
36
</script>
37
38
</body>
39
</html>
40