Skip to content

Instantly share code, notes, and snippets.

@kumkanillam
Created May 12, 2016 05:50
Show Gist options
  • Save kumkanillam/31f40c4ee3e0c475edce22a8d2b8b85d to your computer and use it in GitHub Desktop.
Save kumkanillam/31f40c4ee3e0c475edce22a8d2b8b85d to your computer and use it in GitHub Desktop.
how-to-pass-controller-observed-property-in-component
import Ember from 'ember';
export default Ember.Component.extend({
tagName:'',
currentValue:function(){
return this.get('value');
}.property('value'),
minValue:function(){
return this.get('min');
}.property('min'),
didRender:function(){
this._super(...arguments);
console.log("Render component with currentValue="+this.get("currentValue")+" minValue="+this.get('minValue'));
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
currentVal:50,
currentValChanged:function(){
console.log("currentVal changed : "+this.get('currentVal'));
}.observes('currentVal'),
actions: {
changeCurrentVal(){
this.set('currentVal',Math.floor((Math.random() * 100) + 1));
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<button type="button" {{action "changeCurrentVal"}}>ChangeCurrentVal</button>
{{range-slider min="0" max="100" step="1" value=currentVal}}
<br>
{{outlet}}
<br>
<br>
<br/>
Range Slider Component Controller Observed Property(currentVal) : {{value}}
{{yield}}
{
"version": "0.8.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "1.13.13",
"ember-data": "2.5.2",
"ember-template-compiler": "1.13.13"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment