Last active
April 27, 2016 20:20
-
-
Save krisselden/6bff3f203d11ef01ec51b716865f5385 to your computer and use it in GitHub Desktop.
Complex Prop Bindings
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({ | |
attributeBindings: ['style'], | |
style: Ember.computed('width', 'height', 'color', function() { | |
let width = this.get('width'); | |
let height = this.get('height'); | |
let color = this.get('color'); | |
return 'width:'+width+'px;height:'+height+'px;background-color:'+color; | |
}), | |
color: 'red', | |
height: 20, | |
width: Ember.computed('height', { | |
get() { | |
return this.get('height')*2; | |
}, | |
set(keyName, width) { | |
this.set('height', width/2); | |
return width; | |
} | |
}) | |
}); |
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 MyComponent from './my-component'; | |
export default MyComponent.extend({ | |
color: 'yellow', | |
init() { | |
this._super(...arguments); | |
this.height = 150; | |
} | |
}); |
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', | |
height: 60, | |
width: 80 | |
}); |
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.7.2", | |
"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.12.2", | |
"ember-data": "1.13.15", | |
"ember-template-compiler": "1.12.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment