vue.js - Using Vue in Laravel project -


working on project in laravel , want integrate vue , vue resource it. have setup not working expected. below code:

routes.php

route::get('api/projects', function() {     return app\project::all(); }); 

app.js

new vue({     el: '#project',      data: {         projects: []     },      ready: function() {         this.getprojects();     },      methods: {         getprojects: function() {             this.$http.get('api/projects').then(function(projects) {                 this.$set('projects', projects);             });         }     } }); 

my view

<div class="content" v-for="project in projects">     <h3 class="title">         @{{ project.title }}     </h3>     @{{ project.description }} </div> 

with code above, nothing displayed on page if i

@{{ $data | json }} 

i projects data in json. kind of weird, please doing wrong.

thanks @programmator on laracast. answer solved issue.

this.$set('projects', projects.data); 

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -