Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/371.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript AngularJS-在新浏览器窗口中打开控制器时,单击子窗口会随机触发父窗口上的事件_Javascript_Angularjs_Angular Ui Router - Fatal编程技术网

Javascript AngularJS-在新浏览器窗口中打开控制器时,单击子窗口会随机触发父窗口上的事件

Javascript AngularJS-在新浏览器窗口中打开控制器时,单击子窗口会随机触发父窗口上的事件,javascript,angularjs,angular-ui-router,Javascript,Angularjs,Angular Ui Router,我有一项要求,我正在努力实施,如下所示: 我有一个审计日志页面,其中有一个按钮,可以在新的浏览器窗口上显示日志,同时继续在主窗口中打开的应用程序上执行其他操作。 我们使用ui路由器和angularjs 1.6。以下是我的密码- 通往控制员的路线- .state('auditlog', { url: '/auditlog', templateUrl: 'app/system/audit/audit-log.html', controller: 'A

我有一项要求,我正在努力实施,如下所示: 我有一个审计日志页面,其中有一个按钮,可以在新的浏览器窗口上显示日志,同时继续在主窗口中打开的应用程序上执行其他操作。 我们使用ui路由器和angularjs 1.6。以下是我的密码-

通往控制员的路线-

 .state('auditlog', {
        url: '/auditlog',
        templateUrl: 'app/system/audit/audit-log.html',
        controller: 'AuditLogController',
        controllerAs: 'al'
    })
在不同控制器中的按钮单击事件中,我有以下代码-

unDockEventsPanel(event) {
    let location = this.$state.href('auditlog');
    this.$window.open(location, '', 'scrollbars=no,fullscreen=yes,toolbar=no');
}
以及HTML-

<i class="Icon-MoveOut Icon-Large icon-btn" ng-click="eventsPanelVM.unDockEventsPanel($event)">
现在,当我单击MoveOut按钮时,会调用unDockEventsPanel方法,并打开一个新窗口,其中包含路由定义审核日志中控制器/模板的内容

然而,我面临的问题是,我在子窗口上执行的任何操作都会随机触发父窗口上的其他操作,反之亦然。例如,当我单击子窗口中的选择按钮时,选择按钮在子窗口上打开,但在父窗口上,文本框也会像单击它一样进入焦点。同样,当我在父控件上单击select时,子控件上的另一个控件将高亮显示

我可以看到应用程序/控制器的新实例没有在子级上创建,因此这两个控件和事件之间存在重叠。但我不知道如何把这两个人分开


非常感谢您的帮助。

我相信这个问题与使用“$state”有关

let location = this.$state.href('auditlog');
this.$window.open(location, '', 'scrollbars=no,fullscreen=yes,toolbar=no');

激活状态时,其模板将自动插入其父状态模板的ui视图中

我建议尽量避免使用$state,使用简单的旧Javascript来进行新的窗口导航

window.open("{yourURL}/auditlog", 'scrollbars=no,fullscreen=yes,toolbar=no');

这只发生在我的本地主机上。当我部署它并且有几个窗口时,它们不会重叠。但最终是这样的。$state.href'auditlog';只返回一个类似于/auditlog的字符串,因此,最后我只是将一个字符串传递给window.open。我仍然注释掉了$state代码,并对url字符串进行了硬编码,类似于上面的示例。但这并没有解决问题。