将AngularJS变量发送到新的弹出窗口 [英] Send AngularJS variables to new Popup Window
问题描述
是否可以将AngularJS范围数据发送到新的弹出窗口?
Is it possible to send AngularJS scope data to a new Popup Window?
我正在制作API部分( 示例JSFiddle ),虽然用户可以查看展开的项目,但我的客户想知道我是否可以允许用户将API版本(即帐户1 )推送到新窗口,以防客户希望并排比较某些API。
I am making an API section (Example JSFiddle), and while the user can look at the items expanded out my client was wondering if it would be possible for me to allow a user to push an API version (i.e Accounts 1) to a new window in case the client wished to compare some API's side-by-side.
所以我的问题是,有没有办法在我的 (在新标签中打开) jsfiddle.net/DTcHh/4381/rel =nofollow>示例JSFiddle ,将其包含的数据推送到新的弹出窗口?我不再需要绑定它了,只需将它推到一个新的窗口即可查看。
So my question is, is there any way to utilize the (Open in new tab)
in my Example JSFiddle, to push its containing data to a new pop up window? I would not need to bind it anymore, simply shove it out to a new window for viewing-only.
请记住,对于JSFiddle我手动输入的信息API版本而不是插入我的AngularJS。
在我的实际应用程序中,所有Stuff都是 {{AngularJS_variables}}
。
Keep in mind that for the JSFiddle I manually entered information for the API versions rather than plugging in my AngularJS.
All the "Stuff" are {{AngularJS_variables}}
in my actual application.
我觉得应该有办法将一些数据推送到一个新窗口,但同时我觉得由于我的范围不再存在于父窗口之外而无法实现。
I feel like there should be a way to push some data to a new window, but at the same I feel like that wouldn't be possible due to my scope no longer existing outside of the parent window.
推荐答案
您是否可以将数据存储在localStorage(或sessionStorage)中,然后从新窗口中读取?
Could you not store your data in localStorage (or sessionStorage) then read it from your new window?
类似这样:
//handler for link
$scope.openWindow = function () {
sessionStorage["myData"] = angular.copy($scope.myVars);
window.open("myurl.html") //or a better way to open in a new tab...
};
然后您的新页面只需要读取数据
Then your new page would just need to read the data
var myVars = sessionStorage["myData"];
这篇关于将AngularJS变量发送到新的弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!