[英]click event not working on nginclude in angularjs
I am including a new page using nginclude directive. 我正在使用nginclude指令添加一个新页面。 Click event defined in included page not working.
包含页面中定义的点击事件不起作用。
Main app 主应用
<div ng-app="">
<input type="text" ng-model="ss"/>
<div ng-include src="'include/page1.html'">
</div>
</div>
Page1.html Page1.html
<body>
<div id="a">{{ss}}</div>
<script type="text/javascript">
document.getElementById("a").addEventListener("click",function(){
alert("a");
})
</script>
</body>
why does event defined in page1.html is not working in main app. 为什么page1.html中定义的事件在主应用程序中不起作用。 Is my approach is right or wrong...
我的方法是对还是错...
You can try with: 您可以尝试:
<div id="a" ng-click="clickHere()">{{ss}}</div>
Where clickHere: 单击此处:
$scope.clickHere = function(){ alert('a'); };
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.