如何在Controller - Ember中的action方法中调用方法

时间:2016-03-14 17:11:45

标签: function ember.js methods action

如何使用schoolSearchResults致电searchSchools?我想在调用操作searchSchools时更新学校列表。

export default Ember.Component.extend({
  actions: {
    searchSchools: function(){
      //call schoolSearchResults
    }

  },
  schoolSearchResults: function(){
    alert("schoolSearch");
  }
});

1 个答案:

答案 0 :(得分:0)

由ember组件doc

// ember 2
export default Ember.Component.extend({
  actions: {
    searchSchools(){
      this.schoolSearchResults()
    }

  },
  schoolSearchResults(){
    this.sendAction("searchSchools");
  }
});

// ember 1
    export default Ember.Component.extend({
      actions: {
        searchSchools: function(){
          this.schoolSearchResults()
        }

      },
      schoolSearchResults: function(){
        this.send("searchSchools");
      }
    });