简体   繁体   中英

AngularJS Restangular: How to remove default request param from base url

      EC2Restangular.setBaseUrl('localhost:9000/');
      EC2Restangular.setDefaultRequestParams({
        "Id": ID
      });

Is there any way to remove default query params from baseUrl in Restangular?

To remove the parameters you can just pass an empty object:

EC2Restangular.setDefaultRequestParams({});

If you want to remove the request parameters from a single request, you can add the empty object to the method call like so:

Restangular.all("widget").getList({})

Update: To remove a specific paramter from the default parameter set is a little trickier.

We can grab the parameter list from the Restangular object, and then use that to remove the parameter we don't need, and then use that new parameter object to pass to the new request:

var params = Restangular.all("projects").reqParams;

delete params['parameterNameYouWantToRemove'];

var projects = Restangular.all("projects").getList(params);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM