Reputation: 50742
I am trying to implement a parent/child kind of view as below. i.e. a list is shown initially & on-click of any of the items, I want to be taken to the details view (passing the specific id, making a AJAX request and rendering the child template with the details)
Router.map(function() {
this.route('pending-items', function() {
this.route('pending-items-details', {
path: 'details/:itemId'
});
});
});
My question is do I have to follow specific hiearchy for the folders while creating routes/controllers/templates given the above requirement for pending-items' & 'pending-items-details'
Also how do I render the child template with the details once I have the AJAX response ?
Upvotes: 0
Views: 86
Reputation: 61
I like to do what you want to do in this way:
Router.map(function() {
this.route('pending-items', function() {
this.route('details', {
path: ':item_id'
});
});
});
using Ember-cli , you can do that, if you haven't created yet
this will generate for you this files in template folder
to render the template you only have to put the {{outlet}} helper into the parent template, example :
/peding-items.hbs
<h1>Content of the template</h1>
<div class= 'details'>
{{outlet}}
</div>
/pending-items/details.hbs
<h3> Details of an item</h3>
<p>something here</p>
now run and enter in the browser url put : //localhost:4200/pending-items/1
Upvotes: 1