Ember.js EmberJS-在控制器中观察{{input}}-Helper中的更改

Ember.js EmberJS-在控制器中观察{{input}}-Helper中的更改,ember.js,Ember.js,我的模板中有一个{input}-helper,我想在控制器中为{input}-helper中的每一个更改触发一个方法 application.hbs <div class="page" id="main"> {{input type="text" id="note-title" value=noteTitle action="createNote"}} </div> 有什么建议吗?提前谢谢。不要害怕问问题。我认为在操作散列中使用观察是行不通的。您需要提取该对象外

我的模板中有一个{input}-helper,我想在控制器中为{input}-helper中的每一个更改触发一个方法

application.hbs

<div class="page" id="main">
    {{input type="text" id="note-title" value=noteTitle action="createNote"}}
</div>

有什么建议吗?提前谢谢。不要害怕问问题。

我认为在
操作
散列中使用观察是行不通的。您需要提取该对象外部的
searchTextChanged

YeoApp.ApplicationController = Ember.ArrayController.extend({
  searchTextChanged: function() {
    // this method should be called whenever
    // the input value changes, but somehow it doesn't work
  }.observes("noteTitle"),
  actions: {        
    anotherMethod: function() {
      this.set("noteTitle", "Test!");
      //even this doesn't fire the observer when called
    }
  }
});

我认为在
操作
散列中使用观察是行不通的。您需要提取该对象外部的
searchTextChanged

YeoApp.ApplicationController = Ember.ArrayController.extend({
  searchTextChanged: function() {
    // this method should be called whenever
    // the input value changes, but somehow it doesn't work
  }.observes("noteTitle"),
  actions: {        
    anotherMethod: function() {
      this.set("noteTitle", "Test!");
      //even this doesn't fire the observer when called
    }
  }
});

Ember 2有一个很好的解决方案:
{{input key press=“action”}


请参见《灰烬2》中有一个很好的解决方案:
{{input key press=“action”}


请参见

这很有帮助,但不如某些代码/示例那么有帮助。这很有帮助,但不如某些代码/示例那么有帮助。