我能';无法从我的AngularJS资源中获取索引项

我能';无法从我的AngularJS资源中获取索引项,angularjs,Angularjs,我有以下控制器: .controller( 'AppCtrl', function AppCtrl ( $scope, $location, $resource ) { var Card = $resource('http://localhost/card/:cardId', { 'cardId': "@_id" }, { getAll: { method: 'GET', transformR

我有以下控制器:

.controller( 'AppCtrl', function AppCtrl ( $scope, $location, $resource ) {
    var Card = $resource('http://localhost/card/:cardId',
      {
        'cardId': "@_id"
      },
      {
      getAll: {
        method: 'GET',
        transformResponse: function (data) {
          return angular.fromJson(data)._items;
        },
        isArray: true
      }
    });

    $scope.allCards = Card.getAll();
    console.log($scope.allCards);
    console.log($scope.allCards[0]);
现在,在控制台上,两条打印行显示:

[$resolved: false, $then: function]
    > 0: c
    > 1: c
    > 2: c
    > 3: c
    > 4: c
    > 5: c
    > 6: c
    > 7: c
    > 8: c
    > 9: c
    > 10: c
    > 11: c
    > 12: c
    > 13: c
      $resolved: true
    > $then: function (callback, errback) {
      length: 14
    > __proto__: Array[0]
作为$scope.allCards的值,但作为$scope.allCards的值“未定义”[0]。 我可以将$scope.allCards传递给ng repeat,但我想通过索引选择项,并假设我将获得一个数组,我可以使用它来执行此操作


我的“卡片”返回方法是什么类型的对象,如何从中获取数组?

isArray:true
方法将返回一个承诺,您不能直接对其执行操作

你可以给它传递一个函数


var cards=Card.getAll(函数(){cards[0];})

我希望能够访问其中出现的14项数组。可能它会返回一个实际的承诺,就是这样。对不起,我是JS的新手,对承诺一无所知……我会补充这一点作为回答