简体   繁体   中英

How to get angularjs http request url from options

var httpOptions = {
    url: "http://doman/files",
    method: "GET",
    params : {
        type: pdf,
        page: '112',
        country: "USA",
        lang: "en"                    
    }
};

$http(httpOptions).success(function(data){  });

I am using angularjs. I have an http options to send server. But I want to get the parsed url after succes like this, because I have a lat of params and not want do manually:

http://mydoman/files?type=pdf&page=112&country=USA&lang=en

That is so easy to do with JQuery.param() . If you have JQuery in your project, you can simply use line below :

httpOptions.url + '/?' + $.param(httpOptions.params);

And please do not forget to fix the property type: pdf to type: 'pdf'

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