I've got two models Post.js
and Category.js
Post.js
import DS from 'ember-data';
var Post = DS.Model.extend({
title: DS.attr('string'),
permalink: DS.attr('string'),
body: DS.attr('string'),
category: DS.belongsTo('category')
});
export default Post;
Category.js
import DS from 'ember-data';
export default DS.Model.extend({
name: DS.attr('string'),
permalink: DS.attr('string'),
posts: DS.hasMany('post',{async:true})
});
I'd like to retrieve all posts belonging to a category via http://localhost:4200/<category_permalink>
.
I have trouble to retrieve the data in the route since this doesn't work because of the category.permalink
.
Route
import Ember from 'ember';
export default Ember.Route.extend({
model: function(params) {
return this.store.find('post', { category.permalink: params.category });
}
});
Aucun commentaire:
Enregistrer un commentaire