87,839
社区成员




//定义一个变量
$scope.Data = {};
//把你查询到的json赋给定义的变量
$scope.Data = json;
页面上可以这样写,json中数据多的话就需要做循环遍历
<span ng-bind="Data.author"></span>
<span ng-bind="Data.permlink"></span>
<span ng-bind="Data.category"></span>
<ul>
<li ng-repeat="(key,val) in zzz">
{{key}} : {{ val }}
</li>
</ul>
这样遍历所有字段
感觉你是想遍历里面的那个active_votes 数组,所以要这样:
<ul>
<li ng-repeat="x in zzz.active_votes ">
{{x.voter}} // x即为active_votes 重的每个元素
</li>
</ul>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://cdn.bootcss.com/angular.js/1.6.3/angular.min.js"></script>
</head>
<body>
<div ng-app="myApp" ng-controller="siteCtrl">
<ul>
<li ng-repeat="x in zzz">
{{ x.author }}
</li>
</ul>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('siteCtrl', function($scope, $http) {
$http({
method: 'GET',
url: 'https://api.steemjs.com/get_content?author=smooth&permlink=test'
}).then(function successCallback(response) {
$scope.zzz = response.data;
}, function errorCallback(response) {
// 请求失败执行代码
});
});
</script>
</body>
</html>
按照示例写了个 但是不知道为啥不显示。。。