sfs
October 26, 2018, 8:18am
1
If I use:
App.request.json to load data and put it into a variable called myVar
I can then use template 7 with a for-each to show all records/objects on a page. Great.
But how do I just show one record/object from myVar
Index.html —-> AllDataList.html ——> OneObject.html
Can I use template7 in the last page.
{{$root.myVar.0}}
-> to show first item in myVar
array. You can pass required object index to the OneObject.html page in page query like /one-object/?index={{@index}}
. And it is better to use Component page instead of plain Template7 page so you can easier obtain required element
1 Like
sfs
October 26, 2018, 2:21pm
3
Ok. Thank you.
In one-object.html I can do:
{{root.myVar}} // this works, show [object,object etc]
{{root.myVar.0}} // works. Show first item.
{{$route.params.index}} // works shows index
{{$root.myVar[0].name}} // shows text of first time
But I cannot get passed parameter…
{{$root.myVar[@index ].name}}
or better still, {{name}}
Thank you
You need to use Component http://framework7.io/docs/router-component.html where you will be able to store it into separate variable.
<template>
...
Hello {{item.name}}
</template>
<script>
return {
data() {
item: this.$root.myVar[this.$route.params.index]
},
}
</script>