我遇到点击事件的问题。
我有对象数组:
[
{
id: 1,
title:"Title 1",
name: "Name 1",
hit:true
},
{
id: 2,
title:"Title 2",
name: "Name 2",
hit:true
},
..
]
我在ngFor loop中显示这个
<article class="container">
<custom-item *ngFor="let deal of deals" [deal]="deal" ></custom-item>
</article>
在自定义项目中我有:
<section class="{{getSectionClass()}}">
<header>
<div class="icon">
<i class="wdIcon {{getIconClass()}}"></i>
<span class="points"> {{deal.points}}</span>
</div>
<div class="hit" *ngIf="deal.hit && !checkIsEnded()">HIT</div>
<div class="pointOptions" *ngIf="!checkIsEnded()">
<button md-mini-fab class="minus" (click)="minus()"><span>-</span></button>
<button md-mini-fab class="plus" (click)="plus()"><span>+</span></button>
</div>
</header>
...
</section>
问题在于:
<button md-mini-fab class="minus" (click)="minus()"><span>-</span></button>
<button md-mini-fab class="plus" (click)="plus()"><span>+</span></button>
对于数组大约20个项目,此事件大约3-4次没有被触发。没有任何电话。
组件中的:
minus() {
console.log("minus");
}
plus () {
console.log("plus");
}
有什么建议吗?