Context
In one of my services i return a $resource()-call with different actions like so
return $resource(
'api/someroute/:id',
{
},
{
'getAll': { method: 'GET', isArray: true },
'getById': { method: 'GET', params: { id: '@id' }},
'create': { method: 'POST'},
// 6 more actions with custom url-properties follow...
}
);
I can call all those actions without problems in my controller.
What i am trying
So today i wanted to add the ability to consume a new endpoint and added another action entry:
'getConfiguration': {
method: 'GET',
params: {
id: '@id'
},
url: 'api/someroute/:id/configuration',
}
Problem
When i call the method like
var config = SomeService.getConfiguration({ id: $stateParams.id });
my script breaks with the error output:
SomeService.getConfiguration is not a function
at Object.<anonymous> (http://127.0.0.1:8080/scripts/something/controller.js:233:34)
at invoke (http://127.0.0.1:8080/bower_components/angular/angular.js:4182:17)
at Object.instantiate (http://127.0.0.1:8080/bower_components/angular/angular.js:4190:27)
at http://127.0.0.1:8080/bower_components/angular/angular.js:8453:28
at http://127.0.0.1:8080/bower_components/angular-ui-router/release/angular-ui-router.js:3897:28
at invokeLinkFn (http://127.0.0.1:8080/bower_components/angular/angular.js:8217:9)
at nodeLinkFn (http://127.0.0.1:8080/bower_components/angular/angular.js:7726:11)
at compositeLinkFn (http://127.0.0.1:8080/bower_components/angular/angular.js:7075:13)
at publicLinkFn (http://127.0.0.1:8080/bower_components/angular/angular.js:6954:30)
at updateView (http://127.0.0.1:8080/bower_components/angular-ui-router/release/angular-ui-router.js:3839:23) <div id="mainScope" class="ng-scope" ui-view="">
(anonymous) @ angular.js:11598
(anonymous) @ angular.js:8548
invokeLinkFn @ angular.js:8219
nodeLinkFn @ angular.js:7726
compositeLinkFn @ angular.js:7075
publicLinkFn @ angular.js:6954
updateView @ angular-ui-router.js:3839
(anonymous) @ angular-ui-router.js:3801
$broadcast @ angular.js:14707
(anonymous) @ angular-ui-router.js:3218
processQueue @ angular.js:13175
(anonymous) @ angular.js:13191
$eval @ angular.js:14388
$digest @ angular.js:14204
$apply @ angular.js:14493
done @ angular.js:9650
completeRequest @ angular.js:9840
requestLoaded @ angular.js:9781
load (async)
(anonymous) @ angular.js:9764
sendReq @ angular.js:9619
serverRequest @ angular.js:9335
processQueue @ angular.js:13175
(anonymous) @ angular.js:13191
$eval @ angular.js:14388
$digest @ angular.js:14204
$apply @ angular.js:14493
bootstrapApply @ angular.js:1449
invoke @ angular.js:4182
doBootstrap @ angular.js:1447
bootstrap @ angular.js:1467
angularInit @ angular.js:1361
(anonymous) @ angular.js:26111
fire @ jquery.js:3094
fireWith @ jquery.js:3206
ready @ jquery.js:3412
completed @ jquery.js:3428
Question
Why is this happening & how do i fix this?