I have an Angular component with nested div elements. I want to trigger a click event on the parent div, but if the menu child div is clicked, the parent div’s click event should not be triggered.
Demo@StackBlitz
main.ts
@Component({
selector: 'app-root',
standalone: true,
template: `
<div (click)="openAlert()" class="parent">Parent
<div class="menu">Menu</div>
<div class="child child-2">Child 2</div>
<div class="child child-3">Child 3</div>
</div>
`,
})
export class App {
name = 'Angular';
public openAlert() {
alert('Details View');
}
}