如何解决将数据从控制器传递到模态
我正在尝试从数据库表中获取数据并将其传递给模态,但它说我传入的数组未定义。这是我的控制器:
public function displayLocNotesForModal() {
$notesLoc = Note::all();
return view('/components/callCenter/modalLocNotes',['notesLoc' => $notesLoc]);
}
这是我的路线:
Route::get('/components/callCenter/modalLocNotes','App\Http\Controllers\CallCenter\NoteController@displayLocNotesForModal');
这是我的模态:
<div class="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left">
<h3 class="text-lg leading-6 font-medium text-gray-900" id="modal-headline">
Location #{{ $title }} Notes
</h3>
<div class="mt-2">
<p class="text-sm leading-5 text-gray-500">
{{-- {{ $slot }} --}}
@foreach($notesLoc as $notes)
@if($notes == $title)
works
@endif
@endforeach
</p>
</div>
</div>
解决方法
我认为它应该如下所示,假设 components 文件夹在您的 resources/views
文件夹中
return view('components.callCenter.modalLocNotes',['notesLoc' => $notesLoc]);
还提供文档链接 Laravel nested view directories
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。