Two nested click events with angularjs

后端 未结 3 525
独厮守ぢ
独厮守ぢ 2020-12-25 09:17

I have a HTML structure like this:

3条回答
  •  盖世英雄少女心
    2020-12-25 10:20

    All you need to do is to stop event propagation/bubbling.

    This code will help you:

    ZZZZZ
    XXXXX
    YYYYYY
    ...

    If your test and test2 functions would look as follows, you would get only test2 in your console when clicking on myId DIV. Without $event.stopPropagation() you would get test2 followed by test in the console output window.

    $scope.test = function() {
        console.info('test');
    }
    $scope.test2 = function() {
        console.info('test2');
    }
    

提交回复
热议问题