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