当一个值在*ngFor中更改以通知用户时,我试图突出显示它。到目前为止,我已经完成了以下工作
https://stackblitz.com/edit/ngfor-zhywqy
ngFor由一个名为marks的json对象填充。当用户单击update按钮时,将加载changedMarks,并使用任何更改值的对象执行.find和update marks。我想要做的是将名为.updated的样式应用于已更改值的li:
<ul *ngFor="let mark of marks;" >
   <li>{{ mark.type }}</li>
  <ul>
    <li *ngFor="let outcome of mark.Outcomes;  let i = index"> // add update style here if changed
      {{ outcome.name }} - {{ outcome.value }}
    </li>
  </ul>
</ul>
<button (click)="changeMarks()">Update</button>发布于 2018-07-02 08:58:51
在函数newMark.selected = true中为changedMarks创建一个属性。
然后在html [ngClass]="{'highlight': outcome.selected === true"中。突出显示将是您的css类。
https://stackoverflow.com/questions/51100104
复制相似问题