如何在处理动作后清除输入助手?

Sup*_*ver 4 ember.js

我正在使用Ember v 1.13.8

我有输入助手:

{{input type="text" value=newData action="addNewItem"}}
Run Code Online (Sandbox Code Playgroud)

和动作处理程序:

actions: {
    addNewItem: function(value) {
      this.get('personList').pushObject({name: value});
      this.set('newData', '');
    }
}
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,为了清除输入,我在控制器中有变量存储临时值.我input帮助依赖它,这种方法有效,但我想知道可能有Ember方式这样做吗?

Dan*_*mak 7

你的方法是正确的.我能看到的唯一更多的Ember方法是在声明函数时使用新的JavaScript语法:

actions: {
    addNewItem(value) {
      this.get('personList').pushObject({name: value});
      this.set('newData', '');
    }
}
Run Code Online (Sandbox Code Playgroud)