Reputation: 31
-I'm kind of new to ember js and javascript in general and I can't seem to figure out why my methods keep spitting out the error that both taskData
and personData
are undefined. Any feedback is appreciated!
import Ember from 'ember';
export default Ember.Controller.extend({
taskData: [],
personData: [],
actions: {
taskData: [],
personData: [],
saveTask() {
var task = this.get("task");
taskData.push(task);
},
savePerson()
{
var person = this.get("person");
personData.push(person);
},
print(){
alert(taskData);
alert(personData);
}
}
});
Upvotes: 0
Views: 301
Reputation:
Object keys taskData
and personData
are not variables, but keys of an object which is then passed as an argument to the extend
function. You need to use this
keyword.
import Ember from 'ember';
export default Ember.Controller.extend({
taskData: [],
personData: [],
actions: {
taskData: [],
personData: [],
saveTask() {
var task = this.get("task");
this.taskData.push(task);
},
savePerson()
{
var person = this.get("person");
this.personData.push(person);
},
print(){
alert(this.taskData);
alert(this.personData);
}
}
});
Upvotes: 1