1
是否可以從父控制器訪問itemController的集合? 我有以下代碼:從父控制器訪問itemControllers
App.ShoppinglistController = Ember.Controller.extend(
cartContent: null
actions:
removeSelected: ->
# How to I get each of the cart contents with it's ShoppinglistItemController?
# I want to filter them by the 'isSelected' property
)
App.ShoppinglistItemController = Ember.ObjectController.extend(
isSelected: null
)
App.ShoppinglistRoute = Ember.Route.extend(
setupController: (controller) ->
# [...]
controller.set('cartContent', cartContent)
)
<script type="text/x-handlebars" data-template-name="shoppinglist">
{{#each cartContent itemController="shoppinglistItem"}}
{{title}}
{{view Ember.Checkbox checked=isSelected}}
{{/each}}
<div {{action 'removeSelected'}}>Remove selected items</div>
</script>