gpt4 book ai didi

javascript - 在 Chrome 和 FF 中尝试通过另一个 Angular 应用程序获取一个 Angular 应用程序的根范围时未定义

转载 作者:行者123 更新时间:2023-11-28 01:30:31 25 4
gpt4 key购买 nike

当尝试在新打开的子窗口(使用单独的 Angular 应用程序)中获取根 Angular 范围时,我在 Chrome 和 FF 中收到未定义的消息。

示例:

var childWindowRootApp = childWindowRefeference.angular.element(childWindowRefeference.document.querySelector('[data-ng-app="mainApp"]'));
var rootScope = childWindowRootApp.scope(); // rootScope variable undefined here

相同的代码在 IE10 中运行没有任何故障。

最佳答案

在调用scope()之前尝试在子窗口中的 Angular 上手动调用bootstrap()方法:

childWindowRefeference.angular.bootstrap(childWindowRefeference.document, ["yourApp"]);

关于javascript - 在 Chrome 和 FF 中尝试通过另一个 Angular 应用程序获取一个 Angular 应用程序的根范围时未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22166046/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com