如何在angularjs http服务中将查询参数作为参数传递

时间:2015-11-10 05:04:45

标签: angularjs

如何在angularjs http服务中将查询参数作为参数传递。 我的控制器代码是:

   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){
..
..
..
}

我可以通过在代码中管理查询参数来获取结果而不传递查询参数。 但是我想将查询参数“limitFrom”和“NoOfRows”的值发送给服务,这样我就可以相应地获取数据。可以帮助一些人。

1 个答案:

答案 0 :(得分:1)

尝试使用params选项发送其他数据

get : {
    method : 'GET',
    isArray : true,
    params: /* your data {} */
}