I’ve started playing with ember and trying to combine the WordPress REST API and EmberJS. I‘m stucking with this problem: I want ember to show me all WordPress posts from a certain category or tag.
I have a route that shows me all categories routes/categories.js
that are in the category model models/category.js
. Now I need a route for each category routes/categories/category.js
, that shows me all posts within a certain category.
post
and category
are two models, that I need to get combined I guess, but I do not know how ...
In routes/categories.js
I have something like this
export default Ember.Route.extend({
model() {
return Ember.RSVP.hash({
categories: this.store.findAll('category'),
posts: this.store.findAll('post')
});
},
setupController(controller, model) {
this._super(...arguments);
Ember.set(controller, 'categories', model.categories);
Ember.set(controller, 'posts', model.posts);
}
});
And in templates/categories.hbs
this
<p>List of all categories in the model</p>
<ul>
<li></li>
</ul>
Now I want to see all posts that are in this category routes/categories/category.js
export default Ember.Route.extend({
model(params) {
...???...
}
});
and in templates/categories/category.hbs
?
<h3>List all posts from the selected category</h3>
<ul>
<li></li>
</ul>
Someone able to help with this?
Aucun commentaire:
Enregistrer un commentaire