How can I get the url (and params) from an ng-resource?
And if that is not possible how can I create a wrapper or extend ng-resource so I get this functionality?
Update: I want to be able to extract the URL and params from the resource object without ever sending a request.
In an ideal world the following works:
myResource = $resource('localhost/foo/bar');
myResource.getUrl() // returns localhost/foo/bar
Since the getUrl function doesn't exist I tried the following I found in https://stackoverflow.com/a/28474289/4829972
A wrapping factory:
angular.module('app').factory('ExtendedResourceFactory',['$resource',
function($resource) {
function ExtendedResourceFactory() {
var Resource = $resource.apply(this, arguments);
Resource.prototype.getArguments = function() {
return arguments
};
return Resource;
}
return ExtendedResourceFactory;
}
]);
I inject the new factory and try it out:
res = ExtendedResourceFactory('url')
res.getArguments()
Uncaught TypeError: res.getArguments is not a function(…)
Thankful for directions or solutions!!