Skip to content

Instantly share code, notes, and snippets.

@quincyle
Created May 16, 2017 17:26
Show Gist options
  • Save quincyle/17f943579501e2d03b54c78b4f1b1879 to your computer and use it in GitHub Desktop.
Save quincyle/17f943579501e2d03b54c78b4f1b1879 to your computer and use it in GitHub Desktop.
cp1
import Ember from 'ember';
export default Ember.Component.extend({
cpToRender: Ember.computed('selectedLink', function(){
console.log('componet cp')
return this.get('selectedLink.count')
})
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
count: 0,
count1: 0,
count2: 0,
obj: Ember.Object.create({
count: 0
}),
selectedLink: Ember.computed('count', function() {
return {}
}),
localCp: Ember.computed('selectedLink', function() {
return this.get('obj').set('count', this.get('count'))
}),
actions: {
increaseCount () {
this.set('count1', this.get('count1') + 1)
this.set('count', this.get('count') + 1)
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
localCp: {{localCp}}
<button {{action (action 'increaseCount')}}>Change link obj</button>
{{my-component selectedLink=selectedLink}}
{{outlet}}
<br>
<br>
My component template.
{{cpToRender}}
{{yield}}
{
"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.8.2",
"ember-template-compiler": "2.8.2",
"ember-testing": "2.8.2"
},
"addons": {
"ember-data": "2.12.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment