Reputation: 1211
I am trying to call an API to get some data. In the controller, I do this:
new MyApi.Disconnect('test-item').$save().then(function(response) {...});
This is the service code:
var Disconnect = function (item) {
return $resource('/api/v2/' + item + '/disconnect');
};
return {
'Disconnect': Disconnect
}
item
arrives fine here, but I get this error:
TypeError: (intermediate value).$save is not a function
Please advise what am I doing wrong. Thanks!
Upvotes: 0
Views: 28
Reputation: 1211
I found out that this can be done much simpler:
send the item from the controller:
new MyApi.DisconnectItem({item:'my-item'}).$save().then(function(response) { ...
update the returned statement from the service:
'DisconnectItem': $resource('/api/v2/:item/disconnect', {item: '@item'}),
Upvotes: 0