ui-router:目标标签为"_blank"且对象参数为新选项卡的打开状态 [英] ui-router: open state in new tab with target=“_blank” with object params

查看:95
本文介绍了ui-router:目标标签为"_blank"且对象参数为新选项卡的打开状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ui-router在角度应用程序中进行状态导航,在一种情况下,我必须在其他选项卡中导航到新状态.

I am using ui-router for state navigation in angular application and in one of the scenario I have to navigate to a new state in an different tab.

我处于以下状态

.state("code",
        {
            url: "/code",
            params: { offer : null },
            templateUrl: "app/components/coupons/views/code.html"
        })

参数中的

提供是一个对象. 在同一浏览器中导航到此状态时,它可以正常工作.但是,在其他浏览器中导航到此状态时,商品将为空.

offer in param is an object. When navigating to this state in the same browser it works fine. But when navigating to this state in a different browser offer comes as null.

同一问题由另一个用户在此处发布

The same question was posted by another user here http://stackoverflow.hex1.ru/questions/33232761/ui-router-open-state-in-new-tab-with-target-blank-params-are-lost but here the param is a property and not an object. So, it could be added to url.

谢谢, 山姆

推荐答案

我已经在打字稿中完成了它,并且可以正常工作:

I have done it in typescript and it works:

var myWindow=this.$window;
var myData={data:'testData'};
myWindow.localStorage.myData=JSON.stringify(myData);
window.open(this.state.href('state', {}, {absolute: false, inherit: true}));

然后在新标签的控制器中:

Then in the new tab Controller:

var myWindow=this.$window;
var myData=JSON.parse(myWindow.localStorage.myData);

这篇关于ui-router:目标标签为"_blank"且对象参数为新选项卡的打开状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆