Meteor iron-router - Can I have multiple data sources on a route?

I have an application built using Meteor that uses an Iron Router. My layout uses several output templates, and I would like to pass different data to each of them.

It successfully passes tasks to the taskList template, but does not go through selectedTask to the taskDetail template.

Is it possible to have multiple data sources and is this the right way? And if so, why doesn't it work?

Thanks in advance!: -)

Router.map(function() {
this.route('tasksList', {
    path: '/',
    layoutTemplate: 'layout',
    template: 'tasksList',
    yieldTemplates: {
        'taskDetail': {to: 'rightTemplate'}
    },
    data: {
        tasks: function(){ return Tasks.find() },
        selectedTask: function() { return Tasks.findOne() }
    }
});
});

<template name="layout">
    <section class="wrapper">
        <div class="left-pane">
            {{yield}}
        </div>
        <div class="right-pane">
            {{yield 'rightTemplate'}}
        </div>
    </section>
</template>

<template name="tasksList">
    <ul>
        {{#each tasks}}
            <li>{{detail}}</li>
        {{/each}}
    </ul>
</template>

<template name="taskDetail">
    {{#each selectedTask}}
        <div>{{detail}}</div>
    {{/each}}
</template>
+4
source share
2 answers

Sorry, both of these methods work for me now. I must have had the wrong template name or something like that.

, .

0

selectedTask ( findOne), taskDetail {{#each selectedTask}}{{detail}}{{/each}}. , {{detail}} ?

0

Source: https://habr.com/ru/post/1523789/


All Articles