user9049996
user9049996

Reputation:

StopPropagation in HTML with Angular

I am having a problem with stopPropagation, I don't know how to write in html and typescript for angular. It opens the dialog but at the same time makes a propagation.

Here is my code in HTML:

<label for="tab-two">PROJECTS
    <a class="plus" (click)="opentestdialog()">+</a>
</label>

And here is my code in TypeScript:

opentestdialog() {
    this.dialog.open(TestdialogComponent);
}

Upvotes: 0

Views: 2123

Answers (4)

Johansrk
Johansrk

Reputation: 5250

you can just

<a class="plus" (click)="$event.stopPropagation()">+</a>

Upvotes: 0

user9049996
user9049996

Reputation:

thank's for your time but I have found the problem. I just wrote.

<a class="plus" (click)="opentestdialog(); false">+</a>

Thank you so much, maybe it will be helpfull for someone.

Upvotes: 3

Daniela
Daniela

Reputation: 151

This is the HTML:

<a class="plus" ng-click="opentestdialog($event)">+</a>

This is the typescript file:

public opentestdialog(event: angular.IAngularEvent) {
    event.stopPropagation();
    this.dialog.open(TestdialogComponent);  
}

Upvotes: 0

G&#252;nter Z&#246;chbauer
G&#252;nter Z&#246;chbauer

Reputation: 657078

(click)="$event.stopPropagation();opentestdialog()"

or

(click)="opentestdialog($event)"
opentestdialog(e) {
  e.stopPropagation()
  this.dialog.open(TestdialogComponent);
}

Upvotes: 2

Related Questions