Javascript 在angular中获取api数据
我正在创建一个与angular中的板球比赛信息相关的应用程序。获取api响应时遇到问题。您可以检查api响应。 控制台显示错误,请检查 这是我的密码:Javascript 在angular中获取api数据,javascript,jquery,angularjs,Javascript,Jquery,Angularjs,我正在创建一个与angular中的板球比赛信息相关的应用程序。获取api响应时遇到问题。您可以检查api响应。 控制台显示错误,请检查 这是我的密码: <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> <link rel="stylesheet" href="http://maxcdn.bootst
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body>
<div class="container" ng-app="cricApp" ng-controller="cricCtrl">
<div class="form-group">
<h2>Your result</h2>
<table class="table table-striped">
<thead>
<tr><th colspan="4"><h4>Cricket Match Info</h4></th></tr>
<tr>
<th>Sno</th>
<th>unique_id</th>
<th>description</th>
<th>title</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="match in matchList | filter: nameFilter">
<td>{{$index + 1}}</td>
<td>
{{match.unique_id}}
</td>
<td>{{match.description}}</td>
<td>{{match.title}}</td>
</tr>
</tbody>
</table>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js"></script>
<script>
angular.module('cricApp', []).
controller('cricCtrl', function($scope, $http) {
$scope.matchList = [];
$http.get("http://cricapi.com/api/cricket").then(function (response) {
console.log(response);
$scope.matchList = response.data;
});
}
);
</script>
</body>
</html>
无标题文件
你的结果
板球比赛信息
斯诺
唯一标识
描述
标题
{{$index+1}}
{{match.unique_id}
{{match.description}
{{match.title}
angular.module('cricApp',[])。
控制器('cricCtrl',函数($scope,$http){
$scope.matchList=[];
$http.get(“http://cricapi.com/api/cricket)然后(函数(响应){
控制台日志(响应);
$scope.matchList=response.data;
});
}
);
您的代码很好,只需更换即可
$scope.matchList = response.data;
与
因为实际数据来自response.data中的数据。您的代码很好,只需替换即可
$scope.matchList = response.data;
与
因为实际数据来自response.data中的数据。您可以发布您的
console.log(response)代码>响应?在您收到的错误消息的第一行中,您将看到一个URL(http://errors.angularjs....
),如果您单击该URL,您将无法获得有关您正在获取的错误的信息。请从那里删除该筛选器,然后尝试发布您的控制台.log(响应)代码>响应?在您收到的错误消息的第一行中,您将看到一个URL(http://errors.angularjs....
),如果您单击该URL,您将无法获得有关所获取错误的信息。请从中删除该筛选器,然后重试