celo
1
I would like to know if is possible to hide my sidebar in my application template in my error state.
I have in my application:
<aside class="sidebar">
</aside>
<main class="main">
{{outlet}}
</main>
because in all my templates i have this sidebar, with exception of error.
Thanks.
I would wrap the sidebar with an {{#if showSidebar}}
. Then when you enter your error state, applicationController.set('showSidebar', false)
.
In your template:
{{!-- templates/application.hbs --}}
{{#if showSidebar}}
<aside class="sidebar">
</aside>
{{/if}}
In an error route:
// routes/error.js
export default Ember.Route.extend({
activate() {
this.controllerFor('application').set('showSidebar', false);
},
deactivate() {
this.controllerFor('application').set('showSidebar', true);
}
});
If you don’t have an error route you can use appController: Ember.inject.controller('application')
in another controller to toggle the showSidebar
.
2 Likes