1👍
If you want to request data from a server based on parameters you should send them as GET query params, however if you send a large amount of parameters you should send them in the GET request body (the $http data
field). Angular is fitted to handle JSON, so if you have to handle other data (e.g. XML, CSV) you will have to transform it to JSON. Angular provides a transformRequest
and a transformResponse
function (see here) in the $http
config object to do exactly that (you have to write the logic by yourself though).
$window.location.href
is not suitable as it redirects the browser window to the specified location (usually expecting some html), which would return the data but you’d have no way to interact with it in a JS/Angular context.
I strongly suggest you use $http.get
and transform your data as required. Maybe you find a library that handles the conversion for you.