1

コントローラーに、動的クラスのバインドに使用したい値があります。

isSelected: (->
    this.get('selectedConference') == '1A'
  ).property('selectedConference')

しかし、1Aの代わりに、各ブロックでループされている値と比較したいのです。

  {{each conference in controller.reverseConferences}}
    <li>
      <a>
        {{isSelected}}

{{this}} を isSelected に渡すにはどうすればよいですか?

4

2 に答える 2

0

ここでの解決策は、ビューを作成し、その中でバインディングを行うことでした

App.TeamsConferencesView = Ember.View.extend
  templateName: "teams/conferences"
  selectedBinding: 'controller.selectedConference'
  loadingBinding: 'controller.loadingData'
  ConferenceItemView: Ember.View.extend
    tagName: 'li'
    classNameBindings: 'isActive:active'.w()
    isActive: (->
        this.get('content') == this.get('parentView.selected');
    ).property('item', 'parentView.selected').cacheable()

コントローラーで selectedConference を更新すると、ビューにバインドされ、適切なアイテムがアクティブになります。

私のエンブレムテンプレートは次のようになります

each conference in controller.reverseConferences
  view view.ConferenceItemView contentBinding="conference"
    linkTo teams.conferences conference
      conference
于 2013-04-04T02:03:57.960 に答える