Angular 2 prevent click on parent when clicked on child

后端 未结 3 766
北海茫月
北海茫月 2021-02-02 06:42

I have a click event nested one level. When i click on the child the expected function is called but the parent\'s function is also called. Here is the code

<         


        
3条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-02 06:54

    You need to use stopPropagation() for checkbox event:

    
    

    It prevents further propagation of the current event in the capturing and bubbling phases. You can read more here. Also, you probably need to add stopPropagation() to click event of checkbox, but I'm not 100% sure:

    
    

提交回复
热议问题