2015-11-10 71 views
1

如何將查詢參數作爲angularjs http服務中的參數傳遞。 我的控制器代碼是:我如何通過查詢參數作爲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」的值到服務,以便我acn相應地獲取數據。可以幫助某人。

回答

1

嘗試使用params選項發送額外的數據

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

感謝..它曾爲 – user3415447

+0

歡迎您 –