Justin's Words

AngularJS 制作 F1 车手积分 App

AngularJS 制作 F1 车手积分 App

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
37
38
39
40
41
42
43
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>F1 Feed App</title>
</head>
<body ng-app="F1FeedApp" ng-controller="driverController">
<table>
<thead style="position: fixed; background-color: white">
<tr>
<th colspan="4">Drivers Championship Standings</th>
</tr>
<tr>
<th colspan="4">Search: <input type="text" ng-model="name"></th>
</tr>
</thead>
<tbody>
<tr><td colspan="4">&amp;nbsp;</td></tr>
<tr><td colspan="4">&amp;nbsp;</td></tr>
<tr ng-repeat="driver in driversList | filter:name">
<td>{ { $index + 1 }}</td>
<td>
{ {driver.Driver.givenName + " " + driver.Driver.familyName}}
</td>
<td>{ {driver.Constructors[0].name}}</td>
<td>{ {driver.points}}</td>
</tr>
</tbody>
</table>
</body>
<script src="bower_components/jquery/dist/jquery.min.js"></script>
<script src="bower_components/angular/angular.min.js"></script>
<script>
var app = angular.module("F1FeedApp", []);
app.controller("driverController", function($scope, $http){
$http.get("http://ergast.com/api/f1/2013/driverStandings.json")
.success(function(response) {
$scope.driversList = response.MRData.StandingsTable.StandingsLists[0].DriverStandings;
});
});
</script>
</body>
</html>