【发布时间】:2018-05-29 15:38:38
【问题描述】:
我使用的是最新的 Angular 6。我需要根据用户输入打开一个带有 URL 的新窗口。该 URL 具有指定的返回 URL。 返回 URL 完全加载后,我需要访问 DOM 并从中提取一个元素。
在我的服务中,我有以下代码
getNativeWindow() {
return window;
}
该服务已被注入到如下功能的组件中
onSubmitAuthDetails() {
console.log('onSubmitAuthDetails');
this.nativeWindow = this.loginService.getNativeWindow();
var newWindow = this.nativeWindow.open(this.userInput +
'/Login?returnUrl=//AppLaunch&ia=1');
newWindow.popstate = function (event) {
console.log('event triggered', event);
};
console.log('Window opened done-');
}
新窗口出现在新窗口中,并根据工作流程,最终加载 AppLaunch 页面。 但是我无法弄清楚将捕获此事件的事件? popstate 不起作用。
是否有其他方式或其他事件我必须听?
【问题讨论】: