计算JSON元素的出现次数\频率

时间:2018-12-03 11:43:25

标签: javascript json angular typescript

我有一个使用Angular开发的项目,并且我有一个JSON文件,我需要根据ngFor字段通过RaceName创建对象(分组依据)。 意思是,我需要为每个RaceName创建一个对象。

[
  {"Racename":"A1","Category":34,"Gender":"M","Work":"Amdocs","FullName":"Mark Owen"},
  {"Racename":"A1","Category":34,"Gender":"M","Work":"Amdocs","FullName":"Mark Owen"},
  {"Racename":"A2","Category":34,"Gender":"M","Work":"Amdocs","FullName":"Mark Owen"},
  {"Racename":"A3","Category":34,"Gender":"M","Work":"Amdocs","FullName":"Mark Owen"},
  {"Racename":"A4","Category":34,"Gender":"M","Work":"Amdocs","FullName":"Mark Owen"},
  {"Racename":"A5","Category":34,"Gender":"M","Work":"Amdocs","FullName":"Mark Owen"},
]

因此,根据随附的JSON,我预计只会出现5次。

HTML div标签是: <div class='table' *ngFor = 'let competition of filteredRaceName'> 但是我不确定filteredRaceName方法应该是什么样。

0 个答案:

没有答案