Angularjs ng-repeat样式取决于先前的值

时间:2017-10-20 13:09:04

标签: javascript angularjs

拥有一些数据(大量内部的大量物体。数据看起来像

masses=[
[
  {param1:150, param2:20, param3:"one"},
  {param1:150, param2:21, param3:"one"},
  {param1:150, param2:22, param3:"one"},
  {param1:150, param2:23, param3:"one"},
  {param1:100, param2:24, param3:"one"}
],
[
  {param1:100, param2:26, param3:"one"}
],
[
  {param1:100, param2:26, param3:"two"},
  {param1:150, param2:26, param3:"two"},
  {param1:100, param2:26, param3:"three"}
]

];

enter image description here

是否有任何简单的查看方式如下所示

enter image description here

因此,如果在之前的对象中,同一属性具有相同的值,则会显示,例如opacity:0,4;

https://plnkr.co/edit/g73tRszeVmxfGDbpbDEv

1 个答案:

答案 0 :(得分:2)

构建模型时,标记具有该条件的对象。然后,在循环遍历ng-repeat中的对象时,使用ng-class应用特定的CSS类。

ng-class:https://docs.angularjs.org/api/ng/directive/ngClass