AngularJS and Laravel Foreach



我确实有一个与laravel的foreach循环使用angular的问题,我试图尽可能详细:(

<div style="padding:15px;" id="table-scroll" ng-app>
    <table class="table table-responsive tblProducts" id="tblProducts">
      <thead>
        <tr>
          <th>Description</th>
          <th>Prices</th>
          <th></th>
          <th></th>
          <th>Action</th>
        </tr>
      </thead>                                  
      <tbody>
        //foreach loop here
      </tbody>
    </table>
</div>

这是我的foreach循环

@foreach($ assups as $ product(

{{{$ product-> product_description}}
product_price}}" ng-model =" Price">

@{{price*qty}}}
@EndForeach

问题:

- 当我使用" ng模型"时,价格/数量未显示,但是当我使用" ng cand"时,显示了价格/数量时,显示了nan的价格/数量(我不知道为什么(。

流量:

- 该表的行显示杂货项目列表,当单击复选框时,这意味着该项目已选择并转移到另一个表中以计算孙子。

参考:https://ibb.co/hcddlv(杂货项目列表中的快照(https://ibb.co/e0jk0v(转移该产品时,发生这种情况(*我使用" ng-bind"来显示价格和数量...

感谢提前的答案...

我已经用Laravel中的控制器代码对此进行了更新

公共功能创建(( {
$室=室:: where('状态','=',0( -> orderby('room_length_of_stay'( -> get((;

    $products = DB::table('classifications')
        ->join('products', 'classifications.id', '=', 'products.classification_id')
        ->select('classifications.*', 'products.*')
        ->get();

    //$scope.products = $products;
    return View::make('frontdesk.transactions.create', ['rooms' => $rooms, 'products'=>$products]);
}

ng-model通过使用范围上的属性来读取/写入值,因为输入更改,因此您不能仅分配一些值,因此问题。理想情况下,我仅在前端和模板处理中使用Angular,并且可以通过NG重复进行循环进行循环,该阵列从后端从JS中检索到JS(可能是基于Laravel的(视图,管腔对此有好处(。在短期内,您只能在输入上设置值属性,这将是将数据放入可能与NG模型无法使用的表格中的最直接方法(假设您指出了某些JS属性(NG模型将用于读取/编写值。

而不是使用刀片中的foreach使用ng重复指令。在JSON中获取foreach中的数据并在模板中迭代。

在渲染角控制器之前制作脚本:

<script>
  var products = "{{ json_encode($products) }}";
</script>

然后在控制器存储中以:

$scope.products = products;

然后迭代它:

<p ng-repeat="product in products">
  @{{ product.product_description }}
  @{{ product.price*product.qty}} 
</p>

最新更新