Ember.js create a child controller without route -


i'm trying create child controller limit number of articles retrieved. idea have that:

var homesectioncontroller = ember.objectcontroller.extend({   selectedarticles: functioin(){     // code here   }.property('articles') }); 

first real project using ember , ember-cli i'm still digesting concepts.

this how things looking far:

models/home.js

var home = ds.model.extend({   sections: ds.hasmany('homesection', {async: true}) });  home.reopenclass({   fixtures: [     {       id: 1,       sections: [1, 2]     }   ] });  export default home; 

models/home-section.js

var homesection = ds.model.extend({   title: ds.attr('string') });  homesection.reopenclass({   fixtures: [     {id: 1, title: 'about', articles: [1,2,3,4,5]},     {id: 2, title: 'contact'}   ] });  export default homesection; 

models/home-article.js

var homearticle = ds.model.extend({   title: ds.attr('string') });  homearticle.reopenclass({   fixtures: [     {id: 1, title: 'article 1'},     {id: 2, title: 'article 2'},     {id: 3, title: 'article 3'},     {id: 4, title: 'article 4'},     {id: 5, title: 'article 5'},   ] });  export default homearticle; 

routes/home.js

export default ember.route.extend({   model: function() {     return this.store.find('home');   } }); 

templates/home.hbs

{{partial "home/sections"}} 

template/home/sections.hbs

{{#each model}} <div class="sections">   {{#each sections}}     {{#each articles}}      ... magic happens here!     {{/each}}   {{/each}} </div> {{/each}} 

where create homesectioncontroller. controllers/home-section.js right naming structure?

many thanks,

h

update:

my doubt child controllers without routes, not related ember-cli. anyway, have found discussion here http://discuss.emberjs.com/t/parent-child-controller-relationships-without-using-routes/761/19 answering of questions had before.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -