Angularjs:如何流的HTTP响应新窗口? [英] Angularjs: How to stream http response to new window?
问题描述
我如何使用angularjs $ HTTP
服务发布到服务器的请求,并将结果传输到一个新的浏览器窗口?
我的服务生成和流回来,我想在一个新的浏览器窗口中打开该PDF报表。到目前为止,我一直在使用 $ HTTP
到返回的JSON数据POST请求。我可以使用它来更新模型。这工作正常。但现在我不想从响应中提取数据,只是显示在另一个窗口。也许我应该用一个较低的水平服务,而不是我一直在使用数据交换模式?
$ HTTP(httpPostConfig).success(
功能(数据,状态,头,配置){
...
}
)。错误( 功能(数据,状态,头,配置){
...
}
);
让服务器返回生成PDF的,比使用$窗口服务的唯一标识符来打开一个新的窗口,它的URL指向一个服务器端的端点这返回基于唯一标识符PDF(如 $ window.open('/ PDF / 6234556')
);
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')
);
这篇关于Angularjs:如何流的HTTP响应新窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!