Can't access variable inside another. #3441
-
Codepen: https://codepen.io/rexarvind/pen/xxagrWq <section x-data="{
countries: ['A', 'B', 'C'],
work_address: {
name: 'John',
available_places: this.countries,
}
}">
<ol>
<template x-for="country in work_address.available_places">
<li x-text="country"></li>
</template>
</ol>
</section> |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Well, this is JS. So when you do that, it's using the |
Beta Was this translation helpful? Give feedback.
-
You'll need something like <section x-data="{
countries: ['A', 'B', 'C'],
get work_address() {
return {
name: 'John',
available_places: this.countries,
}
}
}"> as a separate note, the current scope in JS is always hard to grasp and source of bugs, I suppose this is an oversimplified example but it might be wise to find a different data structure |
Beta Was this translation helpful? Give feedback.
You'll need something like
as a separate note, the current scope in JS is always hard to grasp and source of bugs, I suppose this is an oversimplified example but it might be wise to find a different data structure