I'm working with Laravel and I have this link in view A
<div id="app"> <a href="{{ route('ministries.index') }}">Enlace</a> </div>
and I want to click on that link to direct it to view B and show me the results obtained by the controller.
This is the route I have:
Route::resource('ministries', 'Admin\MinistryController');
Vue code:
new Vue({ el: '#app', data: { ministries: [] }, created: function() { this.getMinistries() }, methods: { getMinistries: function() { var url= 'ministries'; axios.get(url).then(response => { this.ministries = response.data }); } } });
Controller code:
public function index() { return Ministry::orderBy('id', 'DESC')->get(); }
The HTML of view B
<tbody> <tr v-for="ministry in ministries"> <td>@{{ ministry.id }} <td>@{{ ministry.name }} </tr> </tbody>