ng-click on parent clicks through children

后端 未结 2 1353
再見小時候
再見小時候 2021-02-03 17:32

I have a

element which has another
element as its child.

I added the ng-click directive to the parent, an

2条回答
  •  滥情空心
    2021-02-03 17:44

    If you want to set different functions for the parent and the child, you can send $event as a parameter for the child function and stopPropagation inside of it. Like this:

    You can click through me

    and in your controller:

    function onChildClick(event){
        event.stopPropagation();
        //do stuff here...
    }
    function onParentClick(){
        //do stuff here..
    }
    

提交回复
热议问题