在我当前的应用程序中,我已经从jQuery调用了许多AngularJS控制器函数,但我刚开始使用strict-di
指令,现在它给了我一个angular().element()
未定义的错误。
我在Angular网站和StackOverflow上搜索了这个问题,但是没有找到任何解决方案,我有30-40个控制器,总而言之我从jQuery调用函数所以我无法改变有没有办法保留我的所有代码并使用strict-di
?
还使用:
app.config(['$compileProvider', function ($compileProvider) {
$compileProvider.debugInfoEnabled(false);
}]);
并在以下位置获取未定义的错误:
var myVar = angular.element(document.getElementById('ControllerID')).scope().FunctionName();
TIA
答案 0 :(得分:0)
我不认为strict-di
是你的问题。
根据范围()的文档 - https://docs.angularjs.org/api/ng/function/angular.element> jQuery / jqLite Extras>方法>范围()
...需要启用调试数据。
你的
$compileProvider.debugInfoEnabled(false);
禁用调试数据,因此angular.element上的scope()(document.getElementById(' ControllerID'))返回undefined。
尝试设置
$compileProvider.debugInfoEnabled(true);