2017-04-17 78 views
0

我正在使用API​​来创建所有数据的表。 JSON网址已连接(我使用200状态进行验证)。我究竟做错了什么?最重要的是,如果有另一种方式来完成我想要做的事情,我是开放的。如何让我的JSON数据显示在页面上?

(function() { 
 
    var app = angular.module("RacingApp", []); 
 
    app.controller("DriversCtrl", function($scope, $http) { 
 
     $http.get("http://ergast.com/api/f1/2013/driverStandings.json?callback=JSON_CALLBACK").then(function(response) { 
 
      $scope.driver = response.MRData.StandingsTable.StandingsLists[0].DriverStandings; 
 
     }); 
 
    }); 
 
})();
<!DOCTYPE html> 
 
<html lang="en"> 
 

 
<head> 
 
    <meta charset="utf-8"> 
 
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
 
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> 
 
    <title>F1 Racing API</title> 
 
    <!-- Bootstrap --> 
 
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> 
 
    <link rel="stylesheet" href="assets/css/main.css"> 
 
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> 
 
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> 
 
    <!--[if lt IE 9]> 
 
     <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> 
 
     <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> 
 
    <![endif]--> 
 
</head> 
 

 
<body ng-app="RacingApp"> 
 
    <div class="container" ng-controller="DriversCtrl"> 
 
     <div class="row"> 
 
      <div class="col-md-8 col-md-offset-2"> 
 
       <table class="table table-striped table-bordered table-compressed"> 
 
        <thead id="table-header"> 
 
         <tr> 
 
          <th colspan="5"> 
 
           <div class="text-left col-md-6">Drivers Championship Standings</div> 
 
           <div class="text-right col-md-6"> 
 
           
 
           </div> 
 
          </th> 
 
         </tr> 
 
        </thead> 
 
        <thead> 
 
         <tr> 
 
          <th>Place</th> 
 
          <th>Nationality</th> 
 
          <th>Name</th> 
 
          <th>Sponsor</th> 
 
          <th>Points</th> 
 
         </tr> 
 
        </thead> 
 
        <tbody> 
 
         <tr ng-repeat="info in information"> 
 
          <th scope="row">{{$index + 1}}</th> 
 
          <td>{{info.Driver.nationality}}</td> 
 
          <td><a href="Driver's Wikipedia Page">{{info.Driver.givenName}} &amp; {{info.Driver.familyName}}</a></td> 
 
          <td><a href="Sponsor's Wikipedia Page">{{info.Constructors[0].name}}</a></td> 
 
          <td>{{info.points}}</td> 
 
         </tr> 
 
        </tbody> 
 
       </table> 
 
      </div> 
 
     </div> 
 
    </div> 
 
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> 
 
    <!-- Include all compiled plugins (below), or include individual files as needed --> 
 
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> 
 
    <script src="https://code.angularjs.org/1.5.7/angular.min.js"></script> 
 
    <script src="js/app.js" type="text/javascript"></script> 
 
</body> 
 

 
</html>

+0

您为同一目的添加了多少个问题? – Sajeetharan

+0

无。我所问的问题纯属情境化。有一件事可能对另一件事不起作用。 –

回答

0

我发现了一个解决方案。无论出于何种原因,我从服务器收到的软件包是MRData.data,它并没有显示在实际的JSON数据中。它现在工作!

相关问题