Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 角度$resource给定错误上的自定义函数“;不是一个函数;_Angularjs - Fatal编程技术网

Angularjs 角度$resource给定错误上的自定义函数“;不是一个函数;

Angularjs 角度$resource给定错误上的自定义函数“;不是一个函数;,angularjs,Angularjs,服务 sampleApp.factory('Order', function ($resource, $cacheFactory) { return $resource('http://example.com/api/v1/orders/:id', {id: '@id'}, { 'query': {method:'GET', cache: true}, 'get': {method:'GET'}, 'updateRow

服务

sampleApp.factory('Order', function ($resource, $cacheFactory) {
  return $resource('http://example.com/api/v1/orders/:id', {id: '@id'}, 
  {
    'query':            {method:'GET', cache: true},
    'get':            {method:'GET'},
    'updateRow':      {method:'POST', params:{charge:true}},
    'deleteRow':      {method:'POST', params:{charge:true}},
    'changeStatus':   {method:'POST', params:{charge:true}}
  });
});
控制器:

$scope.updateRow = function(od){
    var order = od;
    order.$updateRow();
}    
Order.get()和Order.query()工作正常。但当我试图调用我的自定义函数时,它给出了一个错误:order.$updateRow不是一个函数

有人能帮我解释为什么会出现这种错误吗?

试试这个

$scope.updateRow = function(od){
    Order.updateRow({id: od});
}  

我打赌od是资源的创造者,而不是新秩序()??没错,od是什么?