Implementing HTML th and td tags for dynamic column headers and values using ngFor nested loops
P粉949267121
P粉949267121 2023-08-31 15:23:50
0
1
410

I'm trying to create an HTML table with dynamic tr and td. I added a nested loop in the HTML and the dynamic column headers (th) are working fine but the values are not being added to the correct td.

这是我拥有的数据:

"finalResult": [ { "tableNamee": "Table_1", "colCategories": [ { "columnnnn": "User", "values": [ { "value": "0" }, { "value": "10" }, { "value": "60" }, { "value": "0" }, { "value": "0" }, { "value": "0" }, { "value": "0" }, { "value": "0" }, { "value": "0" } ] }, { "columnnnn": "Header1", "values": [ { "value": "460" } ] }, { "columnnnn": "Amount", "values": [ { "value": "10" }, { "value": "100" }, { "value": "50" } ] } ] }, { "tableNamee": "Table_2", "colCategories": [ { "columnnnn": "User", "values": [ { "value": "07" }, { "value": "10" } ] }, { "columnnnn": "Amount", "values": [ { "value": "70" } ] }, { "columnnnn": "User1", "values": [ { "value": "57" } ] }, { "columnnnn": "Column", "values": [ { "value": "80" } ] }, { "columnnnn": "Column2", "values": [ { "value": "10" } ] } ] } ]

以下是HTML代码:

Table Name : {{j.tableNamee}}
{{k.columnnnn}}
{{m.value}}

这里没有特定的ts代码。我只是按照上述格式操作数据,并尝试在HTML中应用循环。我做错了什么吗?

这是期望的输出: 期望的输出

这是我得到的当前输出: 当前输出

任何帮助将不胜感激!

P粉949267121
P粉949267121

reply all (1)
P粉511896716

Your HTML markup looks weird because yourcontains a

that wraps. I think this is what is causing your problem.

I haven't tried it, but you could try changing yourtag to the following:

{{k.columnnnn}}
{{m.value}}

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!