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。