[SOLVED] Passing data to index/home component

Hi there,

in the app I’m trying to build I want to list a bunch of Tours that I retrieve from an API in the main index view. To do that I created a home.html component set the componentUrl to home.html for the path: ‘/’.
Now I can’t figure out why the template is not processing the data.

...
        <div class="page-content">
        <div class="list links-list">
            <a href="/tours/">Tours</a>
            <ul>

                {{$tours}}

                {{#each $tours}}
                <li><a href="/tour/{{t_id}}/">{{name}}</a></li>
                {{/each}}
            </ul>
        </div>
    </div>
</div>
</template>
<script>
console.log(app.data.tours);  // returns {tours: [array 2]} ... just what I need.
return {
    data: function () {
        return {
            // tours: this.$root.tours     <- this doen't do anything
            tours: app.data.tours,        <- this doesn't change anything either
        };
    }
};
</script>

Maybe I understood something completely wrong. Thanks for any clues.

Stupid mistake. Fixed it by removing the dollar signs before the variable name in the template…

1 Like