我正在使用AngularJS,並且我調用了$ resource來獲取單個值(例如獲取14)。
以下是在我的控制器:
var MaxCount = $resource('/maxquestion/fetch', null,
{
getMaxQuestionCount: {method: 'GET', isArray: false}
});
$scope.maxQuestionCount = MaxCount.getMaxQuestionCount();
現在我想要在控制器中使用$scope.maxQuestionCount
,做$scope.maxQuestionCount[0]
給我1
和$scope.maxQuestionCount[1]
給我4
console.log($scope.maxQuestionCount)
我[object Object]
我There are no child objects
我很困惑。如何訪問值14?
感謝您的評論。我一定會考慮這一點,並重寫我編寫的代碼。感謝您的高舉。 – LittleLebowski 2013-05-05 13:32:29
@LittleLebowski更新了答案,提供了代碼示例 – 2013-05-05 13:36:51
非常感謝!真的很感激它。我已經將其更改爲$ http,現在它可以工作。真棒 – LittleLebowski 2013-05-05 13:50:37