dongmeiwei0226 2014-03-27 07:56
浏览 115
已采纳

getList的响应应该是一个数组,而不是一个对象或restangular中的其他东西

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 ?

  • 写回答

1条回答 默认 最新

  • douci1851 2014-03-27 08:10
    关注

    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
        });
    };
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 windows2003服务器按你VPN教程设置后,本地win10如何连接?
  • ¥15 求一阶微分方程的幂级数
  • ¥15 关于#线性回归#的问题:【统计】回归系数要转化为相关系数才能进行Fisher' Z转化吗(相关搜索:回归模型)
  • ¥100 使用matlab解决含分段变量的优化问题
  • ¥15 matlab基于鲸鱼算法优化vmd
  • ¥20 PCB设计与制作问答
  • ¥20 课堂跑如何下载ppt
  • ¥15 STM32阿里云平台显示不了传感器采集的数据
  • ¥20 三菱FX系列PLC上位机串口下指令置位M64和M65,这两条指令分别是什么呢?
  • ¥15 有关结冰模拟程序咨询