buduję aplikację do zarządzania projektami za pomocą rewizji ember.js-PRE3 Ember-data 11.Dostęp do kontrolerów z innych kontrolerów
Jak mogę zainicjować kilka kontrolerów i udostępniają je na całym świecie. Na przykład mam kontroler currentUser i usersController, do których potrzebuję dostępu w każdym stanie. Kiedyś miałem następujący kod w funkcji Ember.ready, ale już nie działa. Podejrzewam, że sposób, w jaki to robiłem, był przeznaczony do debugowania. https://github.com/emberjs/ember.js/issues/1646
stary sposób:
window.Fp = Ember.Application.create
ready:() ->
# Initialize Global collections
appController = @get 'router.applicationController'
store = @get 'router.store'
# User controller sets usersController binding on applicationController
# fetches all team users from server
# json returned from server includes flag "isCurrent"
usersController = @get 'router.usersController'
usersController.set 'content', store.findAll(Fp.User)
appController.set 'usersController', usersController
# CurrentUserController
# sets currentUserController binding on applicationController
# finds currentUser from usersController
currentUserController = @get 'router.currentUserController'
currentUserController.set 'content', usersController.get('findCurrentUser')
appController.set 'currentUserController', currentUserController
@_super()
Co to jest właściwy sposób, aby mieć dostęp do kontrolera CurrentUser we wszystkich stanach aplikacyjnych.