以下是工作代码:
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope, $http) {
$scope.name = 'World';
$http({
url: 'http://landregistry.data.gov.uk/landregistry/query',
headers: { 'Content-type' : 'application/x-www-form-urlencoded',
'Accept' : 'application/sparql-results+json' },
method: "GET",
params: {
query : "select * where {?s a ?o} limit 10",
format: "json"
}
})
.success(function(data, status, headers, config) {
$scope.results = data.results.bindings;
// this callback will be called asynchronously when the response is available
})
.error(function(data, status, headers, config) {
// called asynchronously if an error occurs or server returns response with an error status.
});
});
http://plnkr.co/edit/LfkIPZRsZ4QHTfq2A2vc?p=preview
我怀疑的是如何在数组中存储所有s.values,以便数组可以进一步用于填充下拉菜单而无需将JSON输出保存到外部文件。
感谢。
答案 0 :(得分:0)
您已将结果存储为$scope.results
中的列表。
例如,要在下拉菜单中使用s
的值,您可以执行以下操作:
<select ng-options="item as item.s.value for item in results" ng-model="selected"></select>