How can I use the angularjs $http
service to post a request to the server and stream the result to a new browser window?
My service generates and streams back a pdf report which I'd like to open in a new browser window. So far I've been using $http
to post requests which returned json data. I could use this to update the model. That works fine. But now I don't want to extract data from the response, just display in another window. Perhaps I should be using a lower level service rather than the data exchange pattern I've been using?
$http(httpPostConfig).success(
function(data, status, headers, config) {
...
}
).error(
function(data, status, headers, config) {
...
}
);
Have your server return a unique identifier of the generated PDF and than use $window service to open a new window with it's url pointing to a server-side endpoint which returns PDf based on unique identifier (e.g. $window.open('/pdf/6234556')
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With