这是我的JSON数据Content.json
[{
status: "Allocated",
count: 45
}, {
status: "Bench",
count: 89
}, {
status: "Mobile",
count: 12
}, {
status: "Project",
count: 1
}, {
status: "SAP",
count: 18
}, {
status: "Testing",
count: 68
}, {
status: "vvvv",
count: 70
}];
尝试获取该JSON文件
angular.module('myApp')
.controller('valueController', ['$scope', '$http', '$window', function ($scope, $http, $window) {
var mainInfo = null;
$http({
method : "GET",
url : "/JSON/Content.json",
dataType: 'json',
}).then(function mySucces(response) {
$scope.mainInfo = response.data;
$window.alert(response.data);
}, function myError(response)
{
$window.alert(response.statusText);
});
$scope.chartOptions = {
dataSource: mainInfo,
series: {
argumentField: "status",
valueField: "count",
name: "SIDG Java",
type: "bar",
color: '#1899dd'
}
};
}]);
在警报中,我得到:
Localhost:8080说:
[{
status: "Allocated",
count: 45
}, {
status: "Bench",
count: 89
}, {
status: "Mobile",
count: 12
}, {
status: "Project",
count: 1
}, {
status: "SAP",
count: 18
}, {
status: "Testing",
count: 68
}, {
status: "vvvv",
count: 70
}];
我期望的是
Localhost:8080说:
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],
通过实现您的代码,我在警报中得到了[object,object] [object,object] [object,object]。请再次检查JSON。
如果需要[object,object]结构,则可以通过JSON.parse(response.data)解析数据。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句