Ember transitionToRoute cleanly in a component without sendAction

前端 未结 5 2101
悲&欢浪女
悲&欢浪女 2020-12-28 15:09

How can transitionToRoute be called cleanly from within an Ember component?

It works with injecting a controller into the component and calling the cont

5条回答
  •  北荒
    北荒 (楼主)
    2020-12-28 15:47

    You can use container to get access to any needed part of application. To get application controller :

    this.container.lookup('controller:application')
    

    But what about structure of application - components should generate events - so my opinion it's better to use sendAction. Cause in future you can get situation, when you need to filter such behavior ( for example ) or other application-specific logic before transition

提交回复
热议问题