Ember.js Emberjs-获取组件的值

Ember.js Emberjs-获取组件的值,ember.js,Ember.js,我正在使用一个组件来构建带有余烬的select元素。每次更改一个select值时,我都需要获取每个值。问题是我只能得到更改后的值。如何从管线中选择构件 应用程序的一部分: // the route App.TeamsRoute = Ember.Route.extend({ setupController: function() { // send the values to build the options App.Category.findAll().then

我正在使用一个组件来构建带有余烬的select元素。每次更改一个select值时,我都需要获取每个值。问题是我只能得到更改后的值。如何从管线中选择构件

应用程序的一部分:

// the route
App.TeamsRoute = Ember.Route.extend({
    setupController: function() {
      // send the values to build the options
      App.Category.findAll().then(function(categories) {
        controller.set('categories', categories)
      })
    },

    actions: {
      updateTeams: function() {
        // action triggered when a select is changed
        var controller = this.get('controller')

        // ?????
      }
    }
})

// component to trigger the action
App.CustomSelectComponent = Ember.Component.extend({
  change: function() {
    this.sendAction('action')
  }
})
模板:

// the way I build the element
{{custom-select choices=categories name="category" action="updateTeams"}}

// component template
<script type="text/x-handlebars" id="components/custom-select">
    <select name="{{name}}">
        {{#each choices}}
            <option value="{{unbound value}}">{{name}}</option>
        {{/each}}
    </select>
</script>

组件应该与应用程序无关,反之亦然。也就是说,它们可以对操作或底层模型更改做出反应,比如选择=类别和操作=更新事件。此外,您还可以通过发送的操作发送信息。任何对所发送的操作和信息做出反应的人都应该跟踪该信息,而不是轮询组件

我在下面的jsbin中包含了一个小示例,展示了这个概念


我不确定我的问题是否清楚。以您的示例为例,我想要的是获得updateTeams方法中每个select的值。所以你的意思是这是不可能的?没错,我的意思是,你可以使用jquery来获取所有的值,但是正确的处理方法是,因为你使用的是组件,让组件通过动作来传递信息。