Angular ng-click $event passes child element as target

后端 未结 3 2057
故里飘歌
故里飘歌 2021-02-19 10:06

For each td element in a table I have an attached ng-click. Here is the (simplified) html for each table cell:



        
3条回答
  •  悲&欢浪女
    2021-02-19 10:24

    In Angular 7.x

    myClickHandler($event) {
        this.selectedElement = $event.target.closest('.list-item');
    }
    

    html:

    ...

提交回复
热议问题