gpt4 book ai didi

javascript - Angularjs动态表

转载 作者:行者123 更新时间:2023-11-28 08:32:42 25 4
gpt4 key购买 nike

我有以下 json 字符串来在 angularjs 中生成报告:

{
"result": [{name:"AUS ba",date":"02-01-2014", "result": "pass","time" : "morning","reason":"ok"}],
"result": [{name:"SA ba",date":"02-01-2014", "result": "pass","time" : "afternoon","reason":"ok"}],
"result": [{name: "NZ ba",{"date":"02-01-2014", "result": "fail","time" : "morning","reason":"ok"}],
"result": [{name:"AUS ba","date":"03-01-2014", "result": "pass","time" : "morning","reason":"ok"}],
"result": [{name:"SA ba",date":"03-01-2014", "result": "fail","time" : "morning","reason":"batch failed"}],
"result": [{name: "NZ ba",date": "03-01-2014", "result": "fail","time" : "morning","reason":"batch error"}]

}

目前我正在使用 ng-repeat 生成简单格式的表:

Name        Date       Result  Reason    Time
AU ba 02-01-2014 PASS Ok Morning
AU ba 03-01-2014 ...
AU ba 04-01-2014 ...
...........
...........

现在我想动态创建这样的表

         02-01-2014    02-01-2014    02-01-2014   02-01-2014   03-01-2014  03-01-2014
Morning Morning Afternoon Afternoon Morning Morning
AU ba Pass[Result] ok[Reason] Fail Ok Pass ok
SA ba Fail batch failed

有人可以帮我解决这个问题吗?

最佳答案

您可以制作一个只有一行的表格,然后重复该行中的列。然后,您可以在每一列中制作一个 4 行 1 列的表格:

http://plnkr.co/edit/3xvdGC?p=preview (我重新格式化了您的 JSON 数据以便能够使用它)

但是,如果某些表格单元格的文本需要多行,这就会出现问题。要解决这个问题,您可以使用多个 ng-repeat 语句:

http://plnkr.co/edit/EUKNn5?p=preview

关于javascript - Angularjs动态表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21649441/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com