-
-
Save kumkanillam/9150f8380ba48cab67fcad1ca727ed07 to your computer and use it in GitHub Desktop.
How to bind Route Property to Controller so that route changes will reflect in controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
actions:{ | |
toggleOpen(){ | |
this.sendAction('toggleOpen'); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle' | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
isOpenWrapper:{ | |
value:true | |
}, | |
isOpen:Ember.computed.alias('isOpenWrapper.value'), | |
setupController(controller,model){ | |
this._super(...arguments); | |
controller.set('isOpen',this.get('isOpenWrapper')); //whenever i set route property will this update controller. | |
console.log('setupController'); | |
}, | |
actions:{ | |
toggleOpen(){ | |
console.log('before toggle - ',this.get('isOpen'),' controller',this.controller); | |
this.toggleProperty('isOpen'); //changing this route property is not reflected in controller. | |
//this.controller.toggleProperty('isOpen'); //changing controller is reflecting. | |
console.log('after toggle - ',this.get('isOpen')); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.10.4", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.7.0", | |
"ember-data": "2.7.0", | |
"ember-template-compiler": "2.7.0" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment