Reputation: 5101
I am trying to sort my model. But getting a error as
Cannot read property 'sort' of undefined
any one help me to sort this out? I guess that model
is not existing in Computed
methods.
here is my code :
import Ember from 'ember';
export default Ember.Route.extend({
model(){
return [{"name":"fruit"},{"name":"flowers"}]
},
sortingByKey:['date'],
sorter:Ember.Computed.sort("model","sortingByKey"),
init(){
var sort = this.get("sorter");
}
});
Upvotes: 0
Views: 30
Reputation: 12872
It should be Ember.computed
instead of Ember.Computed
. error says that Ember.Computed
is undefined.
In your code there are some issues,
1. model
is property will be available in controller(which will be set by setupController
2. You can't do this in this.get("sorter")
.
3. date
property is not there in model
Upvotes: 1