Laravel 未定义常量,带有 angularjs ng-repeat error



嗨,我对刀片有问题,如何在函数中传递ng-repeat数组变量

我的代码是

<tr ng-repeat="prod in product">
<td>@{{ prod.id }}</td>
<td>@{{ prod.item_name }}</td>
<td>
<img width="50" height="50" alt="" 
src="{{ ProductController::getProductImage(prod.id) }}"
class="img-responsive">
</td>
</tr>

任何解决方案感谢

您收到该错误是因为

高度="50" alt="  src="{{ ProductController::getProductImage(prod.id( }}"  class="img-response">

PHP只执行一次,PHP 不知道常量prod.id

这段代码,src="{{ ProductController::getProductImage(prod.id) }}",即PHP/Laravel,无法工作,因为它在angular/javascript中运行。您能做的最好的事情就是将该部分作为动态字段移动到产品模型(假设该产品是模型(。之后,您可以像这样使用它:

<img width="50" height="50" ng-src="product.image" class="img-responsive">

最新更新