Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. import Ember from 'ember';
  2.  
  3. export default Ember.Controller.extend({
  4. appName: 'Ember Twiddle',
  5.  
  6. init() {
  7. this.set('parent', this.store.createRecord('parent', {name:'foo'}))
  8. },
  9.  
  10. actions: {
  11. addNewChild() {
  12. console.log(`@ foo`)
  13. const child = this.store.createRecord('child', {parent: this.parent})
  14. this.set('child', child)
  15. },
  16.  
  17. unloadLastChild() {
  18. if (this.child) {
  19. this.child.set('parent', null)
  20. this.child.unloadRecord()
  21. this.set('child', null)
  22. }
  23. }
  24. }
  25. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement