1

In a Laravel blade template I can access some data using @{{list.length}}.

<template id="events-template">
      @{{list.length}}
</template>

How do I use this within a javascript function within the same view template?

Vue is defined in app.js as

var vm = new Vue({
    el: 'body',

});

app.js is called before the script in my view template

3
  • the list.length variable is a javascript variable or a php variable? Commented Apr 20, 2016 at 15:29
  • javascript - within my vue template, I can access it using the @{{variable}} syntax. The @ symbol is used to not confuse blade Commented Apr 20, 2016 at 15:31
  • that's what I though, but I didn't see it in your Vue definition that's why I asked Commented Apr 20, 2016 at 15:32

1 Answer 1

2

First, be sure that you actually have defined the list var in your vue instance

data: {
    list: []
}

Then, to access the list var, use the instance scope, for example in some method

methods: {
    someMethod: function () {
        console.log(list) // undefined
        console.log(this.list) // []
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.