我正在使用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方式这样做吗?
你的方法是正确的.我能看到的唯一更多的Ember方法是在声明函数时使用新的JavaScript语法:
actions: {
addNewItem(value) {
this.get('personList').pushObject({name: value});
this.set('newData', '');
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2670 次 |
| 最近记录: |