如何在同一目录laravel中显示另一个刀片的模态 我有这个按钮来显示 查看
@foreach
<a class="btn btn-primary" data-toggle="modal" data-target="#applicantModal{{$applicant->applicants_id}}">View</a>
@endforech
然后我把它放入 的控制器
public function show()
{
$applicants = Applicant::all();
return view('applicant_list', compact('applicant'));
}
然后是 的模态
<div class="modal fade" id="applicantModal{{$applicant->$applicants_id}}" tabindex="-1" role="dialog" aria-labelledby="applicantModal">
<div class="modal-dialog">
<div class="modal-content">
</div>
</div>
</div>
答案 0 :(得分:1)
您的模态文件可以说abc.blade.php
:
<div class="modal fade" id="applicantModal{{$applicant->$applicants_id}}"
tabindex="-1" role="dialog" aria-labelledby="applicantModal">
<div class="modal-dialog">
<div class="modal-content">
</div>
</div>
</div>
现在你必须在foreach循环中添加Modal文件。
@foreach
@include('path/to/your/modal/file/abc.blade.php');
<a class="btn btn-primary" data-toggle="modal" data-
target="#applicantModal{{$applicant->applicants_id}}">View</a>
@endforech
答案 1 :(得分:0)
您的代码中使用了compact('applicants')
public function show()
{
$applicants = Applicant::all();
return view('applicant_list', compact('applicants'));
}
在你的观点中尝试这样
@foreach($applicants as $applicant)
<a class="btn btn-primary" data-toggle="modal" data-target="#applicantModal{{$applicant->applicants_id}}">View</a>
<div class="modal fade" id="applicantModal{{$applicant->$applicants_id}}" tabindex="-1" role="dialog" aria-labelledby="applicantModal">
<div class="modal-dialog">
<div class="modal-content">
</div>
</div>
</div>
@endforech
希望这有帮助。