문제

when i use the following code in my angularJs controller

var  baseAccount = Restangular.all('account');
    $scope.submit = function(){      
        baseAccount.getList().then(function(accounts) {
            $scope.datas = accounts ;
        });

i get the following error, Response for getList SHOULD be an array and not an object or something else in restangular

is there any solution ?

도움이 되었습니까?

해결책

You're calling getList. which expects the data from the server to be an array (once it's been parsed into a real JS object). Your response is not an array.

You need to fix the server side code to respond with an array or change the Angular code to request a single resource instead of an array of them:

var baseAccount = Restangular.all('account');
$scope.submit = function () {
    baseAccount.get().then(function (account) {
        $scope.data = account; // Only one account
    });
};
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top