每次单击Angular 2中的元素时,都会调用构造函数

时间:2017-04-06 15:27:44

标签: javascript css angular

这是类

的构造函数
<mdl-list *ngFor="let item of notifications" (click)="seeNotification()" >
  <p class="firstLetter" [innerHTML]="item.title.slice(0,-(item.title.length-1))" [style.backgroundColor]="userData.firstLetterColors[math.floor(math.random()*9)+1]">F</p>
</mdl-list>

在HTML中我有以下代码:

this.colors

列表的第一个字母应该从{{1}}数组中选择一些随机颜色。它正在挑选颜色。但是,每当我点击它时,背景颜色也会发生变化。知道为什么会这样吗?

0 个答案:

没有答案