Javascript 未将json数据识别为行(angular.js)
我正在尝试获取一个基本的angular.js页面,以显示通过http get请求从node.js服务器检索到的信息。然而,我遇到了angular无法正确识别json的问题,或者类似的问题。下面是index.htmlJavascript 未将json数据识别为行(angular.js),javascript,angularjs,json,node.js,Javascript,Angularjs,Json,Node.js,我正在尝试获取一个基本的angular.js页面,以显示通过http get请求从node.js服务器检索到的信息。然而,我遇到了angular无法正确识别json的问题,或者类似的问题。下面是index.html <!DOCTYPE html> <html > <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"> </script>
<!DOCTYPE html>
<html >
<script
src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js">
</script>
<body>
<div ng-app="myApp" ng-controller="customersCtrl">
<h1>{{names}}</h1>
<table>
<tr ng-repeat="x in names">
<td>{{ x.title }}</td>
<td>{{ x.pBody }}</td>
<td>{{ x.category }}</td>
<td>{{ x.url }}</td>
</tr>
</table>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
$http.get("http://127.0.0.1:8081/process_get")
.then(function (response) {$scope.names = response.data;});
});
</script>
最后,json数据显示如下,我认为应该可以吗
{"retRows":[{"id":1,"title":"global work and travel co.","pBody":"One of the
worlds leading and largest youth travel
brands","category":"Travel","url":"https://globalworkandtravel.com"},
{"id":2,"title":"travel.com.au","pBody":"One destination endless
possibilities","category":"Travel","url":"https://www.travel.com.au"},
{"id":3,"title":"Flight Centre","pBody":"Australias leading travel
agent","category":"Travel","url":null},{"id":4,"title":"The skinny
confidential","pBody":"lifestyle
blog","category":"Lifestyle","url":"https://www.theskinnyconfidential.com"},
{"id":5,"title":"three years of travel","pBody":"Three years of travel and
adventure from around the
world","category":"Video","url":"https://www.youtube.com/watch?
v=wJF5NXygL4k"}]}
非常感谢您对我的错误操作提供的任何帮助或关于我可以在何处找到更多信息的提示。您必须参考ng repeat指令中名称的retRows属性:
<tr ng-repeat="x in names.retRows">
<tr ng-repeat="x in names.retRows">