简体   繁体   English

按钮在具有 ng-click 的 div 内不起作用

[英]Button not working inside a div which has ng-click

i have a div with ng-click inside that div is a button, when i click the button the function bind with ng-click always execute but not the button, how to just execute the ng-click of button only我有一个带有 ng-click 的 div,该 div 是一个按钮,当我单击按钮时,使用 ng-click 绑定的函数始终执行但不执行按钮,如何仅执行 ng-click 按钮

<div ng-click=redirectToPage()>
    ...
    <button><button>
</div>

You can use stopPropagation() method to prevent the event from bubbling up.您可以使用stopPropagation()方法来防止事件冒泡。

Read more: https://developer.mozilla.org/en-US/docs/Web/API/Event/stopPropagation阅读更多: https : //developer.mozilla.org/en-US/docs/Web/API/Event/stopPropagation

Check demo: DEMO检查演示: DEMO

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM