【发布时间】:2019-12-19 10:00:42
【问题描述】:
我有一个表,其中有一列存储 json 数据,但我无法在视图中循环遍历它。
样本数据:
[
{
"id":28,
"item_id":4,
"item_name":"Texco Dx",
"rate":"15.00",
"unit":"box",
"qty":"20",
"price":300,
"tax":12,
"taxType":"GST",
"tax_paid":36,
"disc":0,
"value":336,
"barcode":"1234ergeg",
"hsn":"q23423",
"lot_number":"1235r23r",
"checked":true,
"error":false,
"returnedQty":12,
"returnedValue":33.6,
"returnedTax":3.6,
"allowedQty":10
},
{
"id":27,
"item_id":3,
"item_name":"Norflox Tz",
"rate":"124.00",
"unit":"qty",
"qty":"10",
"price":1240,
"tax":10,
"taxType":"GST",
"tax_paid":124,
"disc":0,
"value":1364,
"barcode":"11121231",
"hsn":"123213",
"lot_number":"123",
"checked":true,
"error":false,
"returnedQty":3,
"returnedValue":272.8,
"returnedTax":24.8,
"allowedQty":9
}
]
这就是我尝试循环的方式:
<table>
<tr class="left">
<th>SR NO</th>
<th>ITEM NAME</th>
<th>PRICE/UNIT</th>
<th>QTY</th>
<th>DISCOUNT %</th>
<th>TAX</th>
<th>TOTAL</th>
</tr>
@foreach ($bill[0]->ITEM_DETAILS as $item)
<tr>
<td>{{$item->id}}</td>
<td>{{$item0->item_name}}</td>
</tr>
@endforeach
</table>
当我使用 ng-init 存储相同的数据并尝试使用 ng-repeat 对其进行迭代时,它起作用了。
谁能解释一下这种行为。
提前致谢
【问题讨论】:
-
如何在视图中循环遍历该 JSON,您可以编辑您的问题并发布代码吗?
-
这不是此处提供的任何链接的副本。没有一个对我有帮助,或者我可能太蹩脚而无法理解这些。
标签: php laravel-5 laravel-blade