Passing parameters between template hbs pages


#1

app/templates/tasks.hbs: {{outlet}}

Tasks

{{#each model as |task|}}

{{#link-to 'tasks.edit' task.id}}{{task.title}}{{/link-to}}

Created: {{format-date task.created}}
Due: {{format-date task.date}}
Priority: {{task.priority}}

{{task.description}}

Delete
	{{#link-to 'subtasks.subnew' task.id}}<button  class="btn btn-primary">Create SubTask</button>{{/link-to}}

	{{#link-to 'subtasks' task.id}}<button class="btn btn-primary">Show SubTasks</button>{{/link-to}}
</div>

{{/each}}

app/templates/subtasks.hbs: {{outlet}}

SubTasks

{{#each model as |subtask|}}

{{model.id}}

{{subtask.tno}}
{{#if model.id subtask.tno}}

{{#link-to 'subtasks.subedit' subtask.id}}{{subtask.subtitle}}{{/link-to}}

Created: {{format-date subtask.subcreated}}
Due: {{format-date subtask.subdate}}
Priority: {{subtask.subpriority}}

{{subtask.subdescription}}

Delete
{{/if}} {{/each}}

app/routes/tasks.js: import Ember from ‘ember’;

export default Ember.Route.extend({ model(){ return this.store.findAll(‘task’); } });

app/routes/subtasks.js: import Ember from ‘ember’;

export default Ember.Route.extend({ model(){ return this.store.findAll(‘subtask’); } });

Here i couldn’t get the value of task_id passed from tasks.hbs to subtasks.hbs.what should i do to get task_id passed from tasks.hbs to subtasks.hbs?


#2

Ember uses the pattern defined in router.js to know which parameters to pass in the Route.model method. You can then use that parameter to filter records in your store

It looks like you’re already passing the parameter ({{#link-to 'subtasks' task.id}}), you need to get that value from the params argument in the model method of app/routes/subtasks.js