我有一个使用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
方法应该是什么样。