0
我创建了一个web服务,它将我的数据放入列表并将其转换为JSON。以下是我的JSON输出。检索到的JSON列表/数组,无法访问AngularJS上的所有属性
{
GetEventLTResult: [
{
eventID: 1,
location: "Place A",
type: "Community"
},
{
eventID: 2,
location: "Place B",
type: "Community"
},
{
eventID: 3,
location: "Place C",
type: "Movie"
},
{
eventID: 4,
location: "Place D",
type: "Community"
}
]
}
在角度方面,我称之为webservice。我设法检索并显示整个JSON。
$http.get('http://localhost:24007/WebService.svc/GetEventLocationType')
.success(function (JsonObject) {
// Success callback
$scope.message = JsonObject; //manage to output
$scope.message1 = angular.fromJson(JsonObject); //manage to output
$scope.message2 = angular.fromJson(JsonObject.eventID); //unable to output
$scope.EventLTlist = [
angular.fromJson(JsonObject.GetEventLTResult[0].eventID), //manage to output, tried with other arrays
angular.fromJson(JsonObject.GetEventLTResult[0].location) //unable to output, tried with other arrays
];
})
.error(function() {
// Failure callback
$scope.errMsg = "Please try again.";
});
我的目标是检索所有的位置和类型,并填充每个DDL。