I'm new to Vue Js and would like to use it to filter a few dropdown lists, etc. Considering I already have all of the data for the dropdowns in a view model I'd like to pass that data to a Vue instance where I can then filter the dropdowns using Vue.
I've tried putting the data into a simple div, so I can select it into the Vue instance, but it doesn't work. There has to be a better way. Do I have to make a separate call back to the server just to populate the Vue instance?
The code snippet just has a simple array, which I can't seem to load, either.
Eventually want to pull out of this view model
@model MyApp.CatalogViewModels.ViewModel
script here...
new Vue({
el: "#app",
data: {
categories: ["one", "two"]
}
,
methods: {
loadCategories() {
$('#modelData.items').forEach(item => this.categories.push(item))
}
},
created() {
this.loadCategories()
}
})
Mark up...
<div id="app">
<div id="modelData" items=['apple','orange','pear']></div>
<div>
<div>
<ul>
<li v-for="item in categories">
{{ item }}
</li>
</ul>
</div>