2015-03-08 74 views
0

我正在Cloud9中工作,遵循一個教程。我已經到了要將mongo中的數據加載到視圖中的地步。表結構似乎得到生成,但沒有數據填充。getList的響應應該是一個數組而不是一個對象或其他東西

從鉻我看到以下內容:

Error: Response for getList SHOULD be an array and not an object or something else 

,從內部Chrome的頁面加載的響應是:

0: {undefined: {}} 
1: {undefined: {}} 
2: {undefined: {}} 
3: {undefined: {}} 
4: {undefined: {}} 

我查看

<table class="table table-striped"> 
<thead> 
    <th>Title</th> 
    <th>Reason</th> 
    <th>Actions</th> 
    <th>Requester</th> 
    <th>Verified</th> 
</thead> 
<tbody> 
    <tr ng-repeat="change in changes"> 
    <td>{{ change.title }}</td> 
    <td>{{ change.reason }}</td> 
    <td>{{ change.actions }}</td> 
    <td>{{ change.requester }}</td> 
    <td>{{ change.verified }}</td> 
    </tr> 
</tbody> 
</table> 

我的控制器

'use strict'; 

/** 
* @ngdoc function 
* @name clientApp.controller:ChangeCtrl 
* @description 
* # ChangeCtrl 
* Controller of the clientApp 
*/ 
angular.module('clientApp') 
    .controller('ChangeCtrl', function ($scope, Change) { 
     $scope.changes = Change.getList().$object; 
    }); 

我APP.JS

/** 
* @ngdoc overview 
* @name clientApp 
* @description 
* # clientApp 
* 
* Main module of the application. 
*/ 

angular.module('clientApp', ['ngRoute', 'restangular']).config(function ($routeProvider, RestangularProvider) { 

    RestangularProvider.setBaseUrl('http://changebg-MYUSERNAME.c9.io/#:8080'); 

    $routeProvider.when('/', { 
     templateUrl: 'views/main.html', 
     controller: 'MainCtrl' 
    }) 
    .when('/about', { 
     templateUrl: 'views/about.html', 
     controller: 'AboutCtrl' 
    }) 
    .when('/change', { 
     templateUrl: 'views/change.html', 
     controller: 'ChangeCtrl' 
    }) 
    .otherwise({ 
     redirectTo: '/' 
    }); 

}).factory('ChangeRestangular', function (Restangular) { 

    return Restangular.withConfig(function (RestangularConfigurer) { 
     RestangularConfigurer.setRestangularFields({ 
      id: '_id' 
     }); 
    }); 

}).factory('Change', function (ChangeRestangular) { 

    return ChangeRestangular.service('change'); 

}); 

我敢肯定,這是簡單的東西,但我就是不能看到它!

感謝

+0

這是'Change.getList()。$ oject'正確嗎? – dcodesmith 2015-03-08 18:40:58

+0

對不起,這是一個錯字。我糾正了這一點,我得到了同樣的結果。 – ssedwards 2015-03-08 19:15:04

+0

check [this](https://github.com/mgonto/restangular#my-response-is-actually-wrapped-with-some-metadata-how-do-i-get-the-data-in-that- case)out – dcodesmith 2015-03-08 19:30:43

回答

0

只是爲了讓你知道,我已經刪除了restangular現在,直到我明白,如果進一步。我已經回到了爲我工作的基礎知識。

再次感謝

相關問題