Last active
May 9, 2017 20:12
-
-
Save nkgm/9b627057d0fc74455e7f4a05ed29b269 to your computer and use it in GitHub Desktop.
Positional Parameters
This file contains 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'; | |
const {computed} = Ember; | |
const ListPropertiesComponent = Ember.Component.extend({ | |
object: computed.readOnly('params.firstObject'), | |
properties: computed('params.[]', { | |
get() { | |
let [,...props] = this.get('params'); | |
return props; | |
} | |
}) | |
}); | |
ListPropertiesComponent.reopenClass({ | |
positionalParams: 'params' | |
}); | |
export default ListPropertiesComponent; |
This file contains 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'; | |
const MyIfComponent = Ember.Component.extend({ | |
}); | |
MyIfComponent.reopenClass({ | |
positionalParams: ['predicateValue'] | |
}); | |
export default MyIfComponent; |
This file contains 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
// http://www.serabe.com/2016/02/29/the-path-to-contextual-components-understanding-positional-parameters/ | |
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
logContents: "", | |
obj: { a: 'vala', b: 'valb', c:'valc' }, | |
init() { | |
this._super(...arguments); | |
window.log = function(msg) { | |
this.log(msg); | |
}.bind(this); | |
}, | |
log(msg) { | |
let contents = this.get('logContents'); | |
contents += msg + "\n" | |
this.set('logContents', contents); | |
let el = $('#console')[0]; | |
el.scrollTop = el.scrollHeight; | |
}, | |
actions: { | |
clicked() { | |
log('clicked'); | |
} | |
} | |
}); |
This file contains 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
body { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
} | |
#console { | |
position: fixed; | |
height: 400px; | |
width: 100%; | |
bottom: 0px; | |
left: 0px; | |
} |
This file contains 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.12.1", | |
"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.12.0", | |
"ember-template-compiler": "2.12.0", | |
"ember-testing": "2.12.0" | |
}, | |
"addons": { | |
"ember-data": "2.12.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment