How to clear the input helper after the action is processed?

I am using Ember v 1.13.8

I have an input helper:

{{input type="text" value=newData action="addNewItem"}}

and action handler:

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

As you can see, to clear the input, I have a variable in the controller where I store the temporary value. I created a inputhelper dependent on it and this approach works, but I wonder if there could be a way for Ember to do this?

+4
source share
1 answer

Your approach is right. The only clearer way I can see is to use the new JavaScript syntax when declaring a function:

actions: {
    addNewItem(value) {
      this.get('personList').pushObject({name: value});
      this.set('newData', '');
    }
}
+7
source

Source: https://habr.com/ru/post/1626643/


All Articles