如何解决Laravel 中的动态 Bootstrap 模态
我想在 Bootstrap Modal 中动态显示产品详细信息。 这是我的控制器
$products = Product::all();
return view('landing')->with('products',$products);
我的观点
@foreach($products as $index => $product)
<div class="product-text col-lg-6">
<h3><a href="#">{{$product->name}}</a></h3>
<div class="product-Meta">
<p>{{$product->details}}</p>
</div>
<a data-toggle="modal" data-target="{{ $index }}">Modal</a>
</div>
@endforeach
<div class="modal fade" id="{{ $index }}" role="dialog">
<div class="modal-dialog modal-dialog-centered modal-lg">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">{{$product->name}}</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<p>{{$product->description}}</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
如何显示特定产品的详细信息?
解决方法
我们可以使用两种方法来解决这个问题。
-
使用
text = 'Overview At Emburse our mission is to help make our users’ lives — and their businesses – better.We are dramatically transforming how organizations manage corporate expenses and invoices. We humanize work by automating manual tasks and saving users’ time,so they can focus on what matters most — their family,community,or more rewarding work.We help CFO’s give their employees a simple and amazing experience while ensuring.compliance and reducing costs. Our solutions are tailored for companies from start-ups to enterprises. We have more than 14,000 clients and 4.5 million users globally. Embue ' print(len(text)) parser = GingerIt() result=parser.parse(text) print(result)
包含模型代码。 实际上,这不是一个好方法。加载页面需要更多时间,这不是一个好习惯 -
使用
foreach
。这是通过单击按钮在模型上显示您的产品详细信息的最佳方式
所以你可以使用第二种方式。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。