I want to access the IsOpen property that is set in my ApplicationController in my EventsController , but more than that , I want to listen for changes in it , so I’m using the following code :
isOpen: Ember.observer('application.isOpen', function () {
console.log('test');
}),
But is not firing at all.
In my ApplicationController i have the following:
export default Ember.Controller.extend({
isOpen: true,
actions: {
toggleSidebar () {
this.toggleProperty('isOpen');
}
}
});
Am i missing some configuration?
UPDATE:
What i’m trying to do:
In my application template, i’m calling two components, the sidebar and the navbar component. In the navbar component, i have a button, each will send a action to ApplicationController, in order to make the sidebar toggle.
Like this:
ApplicationTemplate:
{{#if session.isAuthenticated}}
{{pc-sidebar
isVisible=showWrappers
isOpen=isOpen
}}
{{pc-navbar
isVisible=showWrappers
isOpen=isOpen
action='toggleSidebar'
}}
{{/if}}
{{outlet}}
So, when i click in the button in my navbav, i send a action to ApplicationController:
actions: {
toggleSidebar () {
this.sendAction('action');
}
}
And in my application controller, i just update the isOpen property:
isOpen: true,
actions: {
toggleSidebar () {
this.toggleProperty('isOpen');
}
}
Now the problem:
I need toggle the main too, each is wrapping all the content, BUT… the MAIN is not in the application template, because only a few templates need it , that would be the case of EventTemplate:
<main class="main">
<!-- content of event template here -->
</main>
So… my solution was make the main a component, and call like this:
{{#main-main isOpen=isOpen}}
<!-- content of event template here -->
{{/main-main}}
Now… i need listen to isOpen that was define in ApplicationController, and i’m struggling with this…
Thanks.