Skip to content

Instantly share code, notes, and snippets.

@siva-sundar
Last active April 26, 2016 10:07
Show Gist options
  • Save siva-sundar/feac7e40694c455bad6f0bacb87943d4 to your computer and use it in GitHub Desktop.
Save siva-sundar/feac7e40694c455bad6f0bacb87943d4 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Component.extend({
didReceiveAttrs() {
console.log('init');
this._super(...arguments);
this.set('currentIndex', this.get('commonIndex'));
this.inc();
},
didRender() {
console.log('render');
this._super(...arguments);
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
commonIndex: 0,
model: [1,2,3],
init() {
this._super(...arguments);
Ember.run.later(this, () => {
Ember.run.scheduleOnce('render', this,() => {
this.set('model', [1,2]);
});
console.log('done');
}, 3000);
},
actions:{
inc(){
this.incrementProperty('commonIndex');
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
controller - index - {{commonIndex}}
<hr>
{{#each model as |item index|}}
{{my-component index=index commonIndex=commonIndex inc=(action 'inc')}}
{{/each}}
<br>
<br>
{
"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.13.13",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.4.3/ember-data.js",
"ember-template-compiler": "1.13.13"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment