Binding values on controllers

I have two controllers, SidebarCategoriesController and MainLinksController. I have a property selectedCategory on SidebarCategoriesController and MainLinksController needs this property when rendering templates.

App.MainLinksController = Ember.ObjectController.extend({
     needs: "sidebarCategories"
});

App.SidebarCategoriesController = Ember.ObjectController.extend({
    selectedCategory:2,
    actions: {
        setCategory: function (id){
            this.set('selectedCategory',id);
        }
    }
});

I also have a templete(below) whose controller is MainLinksController:

<script  type="text/x-handlebars" data-template-name="main_links">
 <h2 class="panel-title">All links:{{controllers.sidebarCategories.selectedCategory}}</h2>
</script>

The issue is that when selectedCategory is being updated in SidebarCategoriesController, the template which is using selectedCategory from MainLinksController via {{controllers.sidebarCategories.selectedCategory}} is not getting updated. How can i make the binding so that as soon as the selectedCategory changes in SidebarCategoriesController, {{controllers.sidebarCategories.selectedCategory}} also changes in the template ?

Could you replicate this in a JSBin please? Glancing at this, I think this should work as is.

look at this example here: Ember Starter Kit// source http://jsbin.com/sihili · GitHub which is in jsbin here, Ember Starter Kit

There are two controllers, SidebarCategoriesController and MainLinksController. I was expecting selectedCategory to be updated in MainLinksController as soon as selectedCategory gets updated in SidebarCategoriesController

Seems possibly related to this ember.js - EmberJS notifyPropertyChange not making it to observer? - Stack Overflow

I think this is a bug, and I’d open an issue.

a workaround for this issue, ember.js - Binding values on controllers - Stack Overflow

Your needs and the render function were actually generating two different instances of sidebar controller. So the alias was actually aliased to a different controller instance.

Fixed: JS Bin - Collaborative JavaScript Debugging

Interesting, wouldn’t have thought that was an error prone way to send up the render.

Yeah, could be a bug. I’d need to investigate. In any case, I’d open up an issue on github and feel free to tag me (@jasonmit). I’d like to dive into this one over the weekend.