ember.js - Set parent controller property from child controller -
i have flyers route has template called flyers.hbs
<div class="button-wrap"> <button {{action 'back'}}>go back</button> {{#if isprintable}} <button {{action 'print'}} class="float-right">print flyer</button> {{/if}} </div> {{outlet}} in flyers route have view , new. new should show button , view should show button , print button. in view controller specified property so.
import ember 'ember'; export default ember.controller.extend({ isprintable: true, }); but parent controller flyers not see property when navigate view route print button not showing.
what proper way this?
as understand you'd have {{isprintable}} in flyers template value dependent of active child route. may looks you.
//flyers controller import ember 'ember'; export default ember.controller.extend({ isprintable: true, }); //child route import ember 'ember'; export default ember.route.extend({ parentcontroller: ember.computed( function() { return this.controllerfor('flyers'); }), setupcontroller: function(controller, model) { this._super(controller, model); this.get('parentcontroller').set('isprintable', false); }, deactivate: function() { this.get('parentcontroller').set('isprintable', true); } });
Comments
Post a Comment