2
我正在按照角$资源错误: error description响应不匹配,配置参数:
Error: error:badcfg
Response does not match configured parameter:
Error in resource configuration for action `array`. Expected response to contain an object but got an {2}
我初始化NG应用程序如下:
var appRoot = angular.module('smapp', ['ngRoute', 'ui.bootstrap', 'ngResource']);
服务:
appRoot.factory('ProgramsResource', function ($resource) {
return $resource('Home/Program', {}, { Program: { method: 'get', isArray: false } })
});
在我的控制器中:
appRoot.controller('ProgramCtrl', function ($scope, ProgramsResource) {
$scope.searchPrograms = function() {
$scope.Programs = ProgramsResource.query(
{
TotalItems: $scope.TotalItems,
ItemsPerPage: $scope.ItemsPerPage,
PageNo: $scope.CurrentPage
});
};
$scope.TotalItems = 175;
$scope.ItemsPerPage = 20;
$scope.CurrentPage = 1;
$scope.searchPrograms();
});
的Json我从服务器respons发送:对于上述JSON
{"TotalItems":175,"ItemsPerPage":20,"PageNo":5,"List":[{"Code":"MATH2014","Name":"Name1","Tags":"Tag1,Tag2"},{"Code":"MATH2015","Name":"Name2","Tags":"Tag1,Tag2"}]}
角$回应抛出错误,但如果我不JSON内发送“列表”阵列和发送简单的JSON如下,一切工作正常然后:
[{"TotalItems":0,"ItemsPerPage":0,"PageNo":0},{"TotalItems":0,"ItemsPerPage":0,"PageNo":0}}]
我是新来的角,不知道我到底在做什么错。
非常感谢。非常基本的错误。 – 2014-09-29 06:18:45