几个月前,ember.js改变了"行动的范围。从按钮点击之类的东西中调用。例如,在下面的车把模板中,如果我点击"保存"
<button type="submit" {{action updateModel model}}>Save</button>
它会起到控制器上的操作的作用,如此
actions: {
updateModel: function(model) {
var name = model.get('name');
//if I want to hit a mixin or instance method
//I am forced to use "send" but how can I send
//state to this method? or is this even the way
//ember wants you to "reuse" code from within
//an action?
}
}
问题是,如果我有一个复杂的动作,我想在控制器之间共享代码。什么是&#34;正确&#34;方式分享即使是简单的&#34;验证&#34;当我被困在&#34;动作&#34;像这样?