Skip to content

Instantly share code, notes, and snippets.

@Srinithi-23
Last active August 23, 2018 09:05
Show Gist options
  • Save Srinithi-23/8e3cf314c7885ec42c06ed3fab236020 to your computer and use it in GitHub Desktop.
Save Srinithi-23/8e3cf314c7885ec42c06ed3fab236020 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Component.extend({
willDestroyElement(){
this._super(...arguments);
Ember.set(this,'model','');
console.log('in child');
}
});
import Ember from 'ember';
export default Ember.Component.extend({
didInsertElement(){
this._super(...arguments);
let model1 = Ember.A(),
model = Object.create({
'display_name':'Srinithi',
'email_id':'[email protected]'
});
model1.pushObject(model);
Ember.set(this,'model',model1);
Ember.set(this,'showing',false);
},
actions:{
show_hide(){
this.toggleProperty('showing');
}
},
willDestroyElement(){
this._super(...arguments);
Ember.set(this,'model','');
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
<br>
<br>
{{memory-leak-parent}}
{{outlet}}
<br>
<br>
<div class="content">
<div class="ui">
<div class="top bottom margin4">
<a class="user">
<span class="user-name">
{{model.display_name}}
</span>
</a>
<div class="meta-mail">
<span class="email-id">{{model.email_id}}</span>
</div>
</div>
</div>
</div>
{{yield}}
<div class="main container">
<br><br><b> This is the parent </b><br><br>
<div class="memory-leak modern">
<div class="leak-parent">
<button {{action 'show_hide'}}>Show/Hide child</button>
{{#if showing}}
{{#each model as |user|}}
{{memory-leak-child model=user}}
{{/each}}
{{/if}}
</div>
</div>
</div>
{{yield}}
{
"version": "0.13.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.16.2",
"ember-template-compiler": "2.16.2",
"ember-testing": "2.16.2"
},
"addons": {
"ember-data": "2.16.3"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment