1

How can i pass query params as arguments in angularjs http services. My controller code is:

   FetchHeadCategoryService.get({
     'officeJndi': officeJndi
      }, function (response) {
     $scope.headCategories = response;
    });

Service.js

   module.factory('FetchHeadCategoryService', [
        '$resource',
        'SYSTEM',
        function($resource, SYSTEM) {
            return $resource(SYSTEM.ENV.API_END_POINT
                    + 'v1/utility/headCategories/:officeJndi ', {
                officeJndi : '@officeJndi'
            }, {
                get : {
                    method : 'GET',
                    isArray : true
                }
            });
        } ]);

HeadCategory.java

public Response fetchDocMgmtHeadCategory(@PathParam(value = "officeJndi") final String officeJndi, @QueryParam(value = "limitFrom") final int limitFrom,@QueryParam(value = "noOfRows") final int noOfRows){
..
..
..
}

I can obtain the result without passing the query params by managing them in the code. But I want to send the value of query params "limitFrom" and "NoOfRows" to the service ,so that i acn fetch the data accordingly.Can somebody HELP.

1 Answer 1

1

Try to use params option to send additional data

get : {
    method : 'GET',
    isArray : true,
    params: /* your data {} */
}
Sign up to request clarification or add additional context in comments.

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.