1

ArrayProxy であり、いくつかの計算された配列を含むコントローラーがあります。

coffeescript では、コントローラーは次のようになります。

MyApp.parentController = Ember.ArrayProxy.create
  content: []
  mothers: (->
    mothers = (person for person in @get("content") when person.sex == 0)
  ).property("content")
  fathers: (->
    fathers = (person for person in @get("content") when person.sex == 1)
  ).property("content")

これは正常に動作し、コマンド ラインから 'MyApp.parentController.get("mothers")' を要求すると、期待される配列が返されます。

今、そのセットをドキュメントに表示したいので、母親のリストを反復処理したいと思います:

<div id="parent-mothers-pool">
  {{#each MyApp.parentController.mothers}}
     {{#view MyApp.ParentView contentBinding="this"}}{{/view}}
  {{/each}}
</div>

これは機能せず、実際にはアプリケーションを完全にハングさせ、コンソールにエラーを出力することさえせずに永久にスピンします。

#each ハンドルバーから「.mother」を除外すると、予想どおり、すべての親が正しく表示されます。しかし、それを置くことはそれを台無しにします。

この計算された配列を反復するにはどうすればよいですか?

4

1 に答える 1

0

コントローラの属性ParentMothersPoolを指す、ビューでバインディングを定義する必要があります。mothers

MyApp.EnclosingView = Ember.View.extend
    mothersBinding: 'MyApp.parentController.mothers'

次に、テンプレートで:

{{#each mothers}}
    ...
于 2012-04-04T14:02:49.050 に答える