Sending an action to containing component

前端 未结 1 1929
清酒与你
清酒与你 2021-01-16 21:22

If I have two components:

  • nav-menu
  • nav-button

and nav-menu is a block component that would contain nav-butt

相关标签:
1条回答
  • 2021-01-16 22:02

    I've run into this issue before and unfortunately, there's no way in the public API to do this. When creating a block component, anything rendered inside of it has the context of the outer scope, not the component. It's unfortunate that there's no way to change this behavior, but it really does make sense.

    I would say that the way you've proposed is the best way to handle this situation: have a variable on the controller that's passed to the outer component. It's inline with Ember's "data down, actions up" philosophy.

    0 讨论(0)
提交回复
热议问题