Angularjs 资源更新方法不是函数

Angularjs 资源更新方法不是函数,angularjs,mean,angularjs-ng-resource,Angularjs,Mean,Angularjs Ng Resource,我使用的是平均堆栈。我试图将PUT请求添加到我的$ngResource中,但出现错误: TypeError: conService.update is not a function at m.$scope.joinCon (http://localhost:3000/javascripts/chirpApp-ngresource.js:217:14) at lb.functionCall (https://ajax.googleapis.com/ajax/libs/angularjs/1.3

我使用的是平均堆栈。我试图将PUT请求添加到我的$ngResource中,但出现错误:

TypeError: conService.update is not a function

at m.$scope.joinCon (http://localhost:3000/javascripts/chirpApp-ngresource.js:217:14)

at lb.functionCall (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.16/angular.min.js:200:64)

at Hc.(anonymous function).compile.d.on.f (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.16/angular.min.js:216:394)

at m.$get.m.$eval (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.16/angular.min.js:126:250)

at m.$get.m.$apply (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.16/angular.min.js:126:476)

at HTMLButtonElement.<anonymous> (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.16/angular.min.js:216:446)

at HTMLButtonElement.c (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.16/angular.min.js:32:389)

有人能帮我找出我的更新中遗漏了什么吗?谢谢

因为它是一个工厂,所以在使用它之前,您应该在控制器代码中实例化它,并执行以下操作:

var cs = new conService();
cs.update(/*params here*/);

有关更多详细信息,请阅读这些精彩文章:,

,因为它是一个工厂,所以在使用控制器代码之前,您应该先在控制器代码中进行实例化,然后再使用以下内容:

var cs = new conService();
cs.update(/*params here*/);

要了解更多详细信息,请阅读那些很棒的帖子:,

$resource
中,非get函数的前缀是
$
conService.$update
有效吗?不幸的是,无效。添加{}停止了错误。这是更新后的代码行…//My factory app.factory('conService',function($resource){return$resource('/api/cons',{},{update':{method:'PUT'}});});现在我得到一个404错误,但我想我可以找到它。在
$resource
中,非get函数的前缀是
$
conService.$update
有效吗?不幸的是,无效。添加{}停止了错误。这是更新后的代码行…//My factory app.factory('conService',function($resource){return$resource('/api/cons',{},{update':{method:'PUT'}});});现在我得到了一个404错误,但我想我可以找到它。我试图直接将你发布的内容翻译到我的代码中,但它不起作用。(编辑:我仍然收到关于我的更新的not函数错误)今晚我将阅读你建议的链接。谢谢你的补充信息!我试着直接将你发布的内容翻译成我的代码,但它不起作用。(编辑:我仍然收到关于我的更新的not函数错误)今晚我将阅读你建议的链接。谢谢你的补充信息!