[英]how to open two modal in the same div in angular 8?
I have a DIV and in the div, there is a link.我有一个 DIV,在 div 中有一个链接。 Now when I click
modalA()
.现在,当我单击
modalA()
。 It opens modalA()
, modalB()
and when I click modalB()
.它打开
modalA()
, modalB()
,当我单击modalB()
。 It opens modalB()
and modalA()
.它打开
modalB()
和modalA()
。 because Both methods are in the same div.因为这两种方法都在同一个 div 中。 So When I click
modalA()
.所以当我点击
modalA()
。 It should open modalA()
only.它应该只打开
modalA()
。 When I click modalB()
.当我单击
modalB()
。 It should open modalB()
only.它应该只打开
modalB()
。 please give me your suggesstion.请给我你的建议。
<div class="a" (click)="modalA()">
<a (click)="modalB()"> </a>
</div>
modalA() {
console.log('A modal');
}
modalB() {
console.log('B modal');
}
Use event.stopPropagation使用event.stopPropagation
Try like this:像这样尝试:
modalB() {
window.event.stopPropagation();
console.log("B modal");
}
or,或者,
.html .html
<div class="a" (click)="modalA()"> aaaa
<a (click)="modalB($event)">bbbb </a>
</div>
.ts .ts
modalB(evt) {
evt.stopPropagation();
console.log("B modal");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.