Ember.js 如何在余烬的内容/选择绑定中指定控制器。选择视图?

Ember.js 如何在余烬的内容/选择绑定中指定控制器。选择视图?,ember.js,Ember.js,我想手动指定余烬的控制器。选择查看: <script type="text/x-handlebars" data-template-name="selected-date-range"> <div class="row"> <div class="col-lg-12"> <div class="well"> <img class="dashboard_icon_small" src="{%=URL('s

我想手动指定余烬的控制器。选择查看:

<script type="text/x-handlebars" data-template-name="selected-date-range">
  <div class="row">
    <div class="col-lg-12">
      <div class="well">
        <img class="dashboard_icon_small" src="{%=URL('static','images/calendar_dashboard_icon_small.png')%}"/>
        <h4>{{content}}
        {{view Ember.Select
          id="locatorSelector"
          contentBinding="Dashboard.LocatorSelectorController.content"
          selectionBinding="Dashboard.LocatorSelectorController.selectedLocator"
          optionLabelPath="content.label"
          classNames="pull-right"}}
        </h4>
  </div>
    </div>
  </div>
</script>

但我不想重复这些数据。为什么控制器不可访问?

这应该可以,但是您有
在之前创建控制器并设置其内容(在路由中)。你做到了吗

更简洁的方法是通过
needs
将所需控制器包含在当前控制器中,您可以在模板中访问它

将其放入控制器:

needs: ['selected_locator']
然后在模板中:

{{view Ember.Select
          id="locatorSelector"
          contentBinding="controllers.selected_locator.content"
          selectionBinding="controllers.selected_locator. selectedLocator"
          optionLabelPath="content.label"
          classNames="pull-right"}}

在“contentBinding”中访问所需控制器的模型。然后您可以直接在“selectionBinding”中引用该模型。见下文:

{{view Ember.Select 
                contentBinding = "controllers.selected_locator.model"
                optionLabelPath = "content.label"
                selectionBinding = "model. selectedLocator"
                classNames = "pull-right"}}
这应该行得通

{{view Ember.Select 
                contentBinding = "controllers.selected_locator.model"
                optionLabelPath = "content.label"
                selectionBinding = "model. selectedLocator"
                classNames = "pull-right"}}