Angularjs: How do I pass an HTTP response to a new window?

How can I use the angularjs $http to send a request to the server and stream the result to a new browser window?

My service creates and sends back a PDF report that I would like to open in a new browser window. So far I have used $http to send requests that returned json data. I could use this to update the model. It works great. But now I do not want to extract data from the answer, I just show it in another window. Perhaps I should use a lower level service, and not the data exchange pattern that I used?

 $http(httpPostConfig).success( function(data, status, headers, config) { ... } ).error( function(data, status, headers, config) { ... } ); 
+6
source share
1 answer

Ask your server to return the unique identifier of the generated PDF file, and then use the $ window function to open a new window with a URL pointing to an endpoint on the server side that returns a PDf based on the unique identifier (for example, $window.open('/pdf/6234556') );

+5
source

All Articles