A lot is written about this problem, but all answers suggests one or more of the following:
stopPropagation
preventDefault
return false
.
But non is working in my case. Here is stackblitz. When button is clicked, desired behaviour is that console shows:
click - button
stop
but it also shows
Click from app component - but it shouldn't happened
This click shouldn't happen (in app.component
):
<my-button [disabled]="true" (click)="onClick()"></my-button>`
public onClick()
{
console.log("Click from app component - but it shouldn't happened");
}
One solution is provided here. But, is creating another span element. Is this really the only option?
Also
native add and remove EventListeners
doesn't looks as elegant solution.