If I have an application using the Router architecture , how do I get the controller of the parent route?
suppose a route like
Router: Ember.Router.extend
enableLogging: true
root: Ember.Route.extend
main: Ember.Route.extend
route: '/'
connectOutlets: (router, event) ->
router.get('applicationController').connectOutlet('main')
editor: Ember.Route.extend
route: '/editor'
connectOutlets: (router, event) ->
router.get('mainController').connectOutlet('editor')
So how would my EditorController
get a hold of my MainController
?
I've tried @get('parentController')
, @get('parent')
, and @get('controller')
with no success
You can access the router through the target
property of a controller.
eg, in your case, from any controller:
@get('target.mainController')
Or, if you do not use head revision of Ember:
@getPath('target.mainController')
According to my understanding, an application is supposed to have only one router, so why dont we just do:
@get('App.router.mainController')
I have no idea on what is the right approach! I feel like 'target' is storing the object to which actions or events are dispatched.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.