event.preventdefault() in angular 8 code example
Example 1: angular stoppropagatio
import {Directive, HostListener} from "@angular/core";
@Directive({
selector: "[click-stop-propagation]"
})
export class ClickStopPropagation
{
@HostListener("click", ["$event"])
public onClick(event: any): void
{
event.stopPropagation();
}
}
Example 2: event.preventdefault() in angular
<!-- Angular 2+ -->
<button (click)="$event.preventDefault()"></button>
<!-- AngularJS -->
<button ng-click="$event.preventDefault()"></button>