我在页面中有两个ng-app
(我知道这是一个错误的方法,但我真的不得不这样做)。它起作用,除非我尝试将clicklistener添加到正文
angular.element(document.body).click(function(event){
// Code
}
使用Javascript:
var appElement = document.getElementById("MyApp");
angular.bootstrap(appElement, ['MyApp']);
HTML:
<div id="MyApp" ng-controller="MyApp">
// Other HTML
</div>
错误:
Uncaught TypeError: angular.element(...).click is not a function
我调试了两个场景。以下对象是angular.element(document.body)
没有引导程序的结果:
m.fn.init [body.ms-backgroundImage, context: body.ms-backgroundImage]
0:body.ms-backgroundImage
context:body.ms-backgroundImage
length:1
__proto__:Object(0)
这与bootstrap:
m.fn.init [body.ms-backgroundImage]
0:body.ms-backgroundImage
length:1
__proto__:Object(0)
为什么会出现这种差异?可能是问题吗?我该如何解决?