Is there any way to get a hand on the model from a controller? I would need to call an instance method defined on the model and
this.get(methodName)(params)
does not work, as it loses the 'this' call context within the called function.
Thank you.
Is there any way to get a hand on the model from a controller? I would need to call an instance method defined on the model and
this.get(methodName)(params)
does not work, as it loses the 'this' call context within the called function.
Thank you.
I'm not sure which context you want to exist in the method, if you need to switch the context you can use call/apply. The context should be the context of the method, not the controller by javascript standards.
var model = this.get('model');
model.methodName(arg1, arg2);
model.methodName.apply(this, arrayOfArgs);
model.methodName.call(this, arg1, arg2);