AngularJS $resource 错误 - TypeError: Object #<g>没有方法“推" [英] AngularJS $resource error - TypeError: Object #<g> has no method 'push'

查看:23
本文介绍了AngularJS $resource 错误 - TypeError: Object #<g>没有方法“推"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的控制器文件中有以下内容:

I have the following in my controller file:

var Subject = $resource('/api/TestAccounts/:action', { applicationId: 3 }, {
   'getSelect': { method: 'GET', params: { action: 'GetSelect' } }
});

Subject.getSelect({ applicationId: 3 },
   function (resp) {
      $scope.testAccounts = resp;
      gridData = null;
   }
);

我的服务器代码运行并返回:

My server code runs and returns:

[{"id":5,"name":"xxx"},{"id":6,"name":"yyy"}]

但是我收到以下错误:

TypeError: Object #<g> has no method 'push'
    at copy (http://127.0.0.1:81/Scripts/angular.js:577:21)

有人知道我做错了什么吗?

Does anyone have any idea what I am doing wrong?

推荐答案

我刚刚将 MyService.get(...) 更改为 MyService.query(...) 因为 .get() 需要一个对象,而 .query() 需要一个数组.

I just changed MyService.get(...) to MyService.query(...) because .get() expects an object and .query() expects an array.

这篇关于AngularJS $resource 错误 - TypeError: Object #&lt;g&gt;没有方法“推"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆