Can't Access Ember's Class Variable
How to properly pass a variable to an Ember's class? Controller: import Controller from '@ember/controller'; import Object from '@ember/object'; function totalVotes(company) { r
Solution 1:
var appModel = AppModel.create({
companies: getCompaniesJSON().map(function(json) {
return Company.create(json);
})
});
should something like this (untested):
var appModel = AppModel.create({
init() {
this._super(...arguments);
this.set('companies', getCompaniesJSON().map((json) => {
returnCompany.create(json);
});
}
});
i'm assuming the code is written this way (with global variables) for illustrative purposes and so i will ignore the other issues with the code sample that are likely not present in your real code, such as the property in your controller needing to be a computed.alias instead of direct assignment etc.
Post a Comment for "Can't Access Ember's Class Variable"