我对角度有点陌生,我的 json 和 ng-repeats 有问题。我有一个“模块”列表,然后是其中的“周”列表:
{
"modules":
{
"module1":
{
"title":"name of module1",
"description":"description of module1",
"weeks":{"week1":{"title":"Week 01"}
},
"module2":
{
"title":"name of module2",
"description":"description of module2",
"weeks":{"week2":{"title":"Week 02"},"week3":{"title":"Week 03"}
}
}
}
我的最终输出是一个表格,我可以让模块重复,但我很难通过让几周循环来理解我做错了什么。这是我的模板:
<table class="table table-bordered" ng-repeat="module in ocw.modules">
<tr>
<td>
<h3 class="moduletitle">{{ module.title }}</h3>
<h4>Description</h4>
<p>{{ module.description }}</p>
</td>
</tr>
<tr ng-repeat="week in ocw.modules.weeks">
<td>
{{ week.title }}
</td>
</tr>
</table>
所以这将输出 2 个表格,带有正确的标题和描述,但我似乎无法正确显示周数。请注意,某些“模块”有不止一个“周”。我不确定错误是在我的模板还是 json 中。
谢谢你的帮助。小号