我正在尝试执行多个 ng-repeat,以便我可以访问 json 中的第三级数组并显示在 table 中,但无法正常工作
I am trying to execute multiple ng-repeat so that I can access a third level array in my json and display in a table but can't get this working
我正在尝试嵌套 ng-repeat,但看起来我做的不正确。
我需要显示 json 中的所有 lineItem。
因为 json 我试图显示的值是第 3 级数组,我尝试嵌套
ng-repeat 但不起作用。
<table border="1" width="100%">
<tr>
<th>Id</th>
<th>materialNumber</th>
<th>quantity</th>
</tr>
<tbody ng-repeat="subConfig in values.subConfigs.subConfig">
<tr ng-repeat="lineItem in subConfig.lineItems.lineItem">
<td>{{lineItem.lineItemId}}</td>
<td>{{lineItem.materialNumber}}</td>
<td>{{lineItem.quantity}}</td>
</tr>
</tbody>
</table>
您的 json 格式不正确,值不应该是数组,您还需要将 ng-repeat="s in values.subConfigs.subConfig">
更改为 ng-repeat="s in values.configBOM.subConfigs.subConfig">
类似
<tbody ng-repeat="s in values.configBOM.subConfigs.subConfig">
<tr ng-repeat="lineItem in s.lineItems.lineItem">
<td>{{lineItem.lineItemId}}</td>
<td>{{lineItem.materialNumber}}</td>
<td>{{lineItem.quantity}}</td>
</tr>
</tbody>
这是一个非常小的错误:
请将您的 json 更改为对象而不是数组,您提供的格式有误。
所以应该是:
$scope.values={} //whatever you want to write inside
而不是:
$scope.value=[];
其次,当您执行 ng-repeat 时,您必须更改此行:
<tbody ng-repeat="subConfig in values.subConfigs.subConfig">
至:
<tbody ng-repeat="subConfig in values.configBOM.subConfigs.subConfig">
我正在尝试嵌套 ng-repeat,但看起来我做的不正确。 我需要显示 json 中的所有 lineItem。
因为 json 我试图显示的值是第 3 级数组,我尝试嵌套 ng-repeat 但不起作用。
<table border="1" width="100%">
<tr>
<th>Id</th>
<th>materialNumber</th>
<th>quantity</th>
</tr>
<tbody ng-repeat="subConfig in values.subConfigs.subConfig">
<tr ng-repeat="lineItem in subConfig.lineItems.lineItem">
<td>{{lineItem.lineItemId}}</td>
<td>{{lineItem.materialNumber}}</td>
<td>{{lineItem.quantity}}</td>
</tr>
</tbody>
</table>
您的 json 格式不正确,值不应该是数组,您还需要将 ng-repeat="s in values.subConfigs.subConfig">
更改为 ng-repeat="s in values.configBOM.subConfigs.subConfig">
类似
<tbody ng-repeat="s in values.configBOM.subConfigs.subConfig">
<tr ng-repeat="lineItem in s.lineItems.lineItem">
<td>{{lineItem.lineItemId}}</td>
<td>{{lineItem.materialNumber}}</td>
<td>{{lineItem.quantity}}</td>
</tr>
</tbody>
这是一个非常小的错误:
请将您的 json 更改为对象而不是数组,您提供的格式有误。
所以应该是:
$scope.values={} //whatever you want to write inside
而不是:
$scope.value=[];
其次,当您执行 ng-repeat 时,您必须更改此行:
<tbody ng-repeat="subConfig in values.subConfigs.subConfig">
至:
<tbody ng-repeat="subConfig in values.configBOM.subConfigs.subConfig">