I am using Laravel and want to create a simple edit application for editing a post. I am using Vue.js 2 to bind the data, but somehow it will not display it - and I am unsure what could be wrong. When I display the data using Vue's e.g of @{{ postData.title }} it displays the title on the page. But I want to display the data inside a input so that it can be edited. The routing and everything is fine, because I get the correct URL and I can display the data in Vue just not in the textboxes. Thanks in advance.
Here is my HTML:
<div id="postEdit">
<div class="container">
<div class="row">
<form class="form-horizontal" method="POST">
<meta id="_token" content="{{ csrf_token() }}">
<h1>Edit your post</h1>
<div class="form-group">
<label for="title">Title</label>
@{{ postData.title }}
<input type="text" name="title" id="title" class="form-control" v-model="postData.title">
</div>
<div class="form-group">
<label for="post">Post</label>
<textarea name="post" rows="8" cols="80" id="post" class="form-control" v-model="postData.post"></textarea>
</div>
<input type="submit" name="submit" value="Submit Post" id="submit" class="btn btn-primary">
</form>
</div>
</div>
</div>
Here is the Vue.js:
var edit = new Vue({
el: '#postEdit',
data: {
postData: <?php echo $post ?>,
},
methods: {
},
});
My controller:
public function edit($id){
$post = Post::find($id);
return view('post.edit', compact('post'));
}