2

I am trying to build a resource in Restangular with a URL that has multiple variables. The server variable is set, so I need to figure out how to do this client side.

This is the URL that I was using in ngResource:

'/api/v1/reports/shipped-orders/:reportDate/:orderType'

There isn't really any nesting past shipped-orders, it's just passing parameters through the URL.

I tried chaining them like:

_reports.one('shipped-order', '2013-11-04').one('', 'bulk')

But that turned out a url with double slashes in it.

2 Answers 2

3

I recently ran into this problem. Here's what I did:

myApp.factory('myRestService', ['Restangular', function(Restangular) {
    return {
        myFunction: function(varA, varB, varC) {
            var path = "rest/primaryPath/" + varA + "/" + varB + "/" + varC;
            var restObject = Restangular.all(path);
            var thePromise = restObject.getList();

            return thePromise;
        }
    };
}]);

By building the path myself, I was successfully able to use more than one variable and get a result from the Java Rest Service I was using in my project.

Sign up to request clarification or add additional context in comments.

1 Comment

Awesome and thanks! I ended up just using straight $http, but I'll definitely give this a shot next time.
1

It is also possible to do the following:

Restangular.all(varA).all(varB).all(varC);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.