我正在使用Cloud9,在教程之后。我已经到了我正在尝试将mongo中的数据加载到视图中的位置。表结构似乎已生成但未填充数据。
从Chrome我看到以下内容:
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 :(得分:0)
只是为了让你知道我现在已经移除了restangular,直到我明白了。我已经回到了对我有用的基础知识。
再次感谢