i'm a beginner of Ember.js and i have some trouble with model/controller.
I have a structure like this:
router.js
Router.map(function() {
this.route('search', function() {
this.route('detail', { path: '/:search_id' });
this.route('ranks', { path: '/:search_id/ranks' });
this.route('tweets', { path: '/:search_id/tweets' });
});
});
export default Router;
route/search.js
import Ember from 'ember';
export default Ember.Route.extend({
});
route/search/rank.js
export default Ember.Route.extend({
model(params) {
return this.get('store').findRecord('search', params.search_id);
},
setupController: function(controller, model) {
controller.set('model', model);
}
});
app/models/rank.js
export default DS.Model.extend({
date: DS.attr(),
tag: DS.attr('string'),
rank: DS.attr('number'),
freq: DS.attr('number'),
search: DS.belongsTo('search')
});
app/models/search.js
export default DS.Model.extend({
uniqueid: DS.attr('string'),
idate: DS.attr('date'),
fdate: DS.attr('date'),
keywords: DS.attr(),
ranks: DS.hasMany('rank')
});
app/controllers/search.js
export default Ember.Controller.extend({
});
app/controllers/search/rank.js
export default Ember.Controller.extend({
mydata: Ember.computed('model', function() {
this.get('model').forEach(function(item) {
console.log(item);
});
});
});
This generate this error:
Uncaught TypeError: this.get(...).toArray is not a function(…)
I have read a lot of possible solution but i can't find the right one. Please can you help me? Thank you in advance.
Aucun commentaire:
Enregistrer un commentaire