[英]Unable to get scope in content script Firefox Addon
I am developing an addon for Firefox. 我正在为Firefox开发插件。 In a content script file I have the line 在内容脚本文件中,我有一行
angular.element(document.getElementById("angularAppDiv")).scope();
it returns null
. 它返回null
。 However if I type the same line into the browser console, I get the scope object? 但是,如果我在浏览器控制台中键入同一行,是否得到了范围对象? Could someone point out what's happening and why? 有人可以指出发生了什么事,为什么?
By default, content scripts loaded by add-ons and scripts loaded by web pages are insulated from each other: 默认情况下,加载项加载的内容脚本和网页加载的脚本相互隔离:
What you could do is to insert this script tag from content script into the page: 您可以做的是将此脚本标记从内容脚本插入页面:
document.head.innerHTML = document.head.innerHTML + '<script> console.log(angular.element(document.getElementById("angularAppDiv")).scope());</script>';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.