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 ?
Aucun commentaire:
Enregistrer un commentaire