I am developing an Ember app and it is really great. But I have a annoying problem I can not solve. I use routing in my app and two diffent controllers with their own views. If I try to use a binding property from the first controller to the second one, that property is not reflected in the second view. In a short way I have something like this:
router = Em.Router.extend({.....});
App = Em.Application.create({
Router: router,
FirstCtrl: Em.Controller.extend({x:'ABC'}),
FirstView: Em.View.extend({...}),
SecondCtrl: Em.Controller.extend({xBinding:'Em.App.router.firstCtrl.x', y:'123'}),
SecondView: Em.View.extend({...}),
});
App.initialize();
Em.App = App;
If in the template for the second view I have something like this:
Binding property: {{x}}
Property with no binding: {{y}}
‘ABC’ is not shown in the view but there is no such problem with ‘123’.
In my browser I can access that property from Javascript console with Em.App.router.firstCtrl.x but Em.App.router.secondCtrl.x returns undefined.
So, my question is Why can’t I access that property? How should I write that binding?
Thanks in advance for your help
I don’t think
Emat the beginning of binding is required, Try this..Well summing up the comments:
controllersdefined in ember must end with Controller while routing, for example if you callrouter.get('applicationController').connectOutlets('home')its corresponding controller shall beApp.HomeControllerorApp.homeController'App.router.yourController.yourProperty'instead of'Em.App.router.yourController.yourProperty'connectControllersin order access properties across controllers if you want to avoid global bindings