Created
October 3, 2016 12:51
-
-
Save ultimatemonty/399e7db4651619e059a35d4f29e4a89c to your computer and use it in GitHub Desktop.
Contextual Components
This file contains hidden or 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'; | |
export default Ember.Component.extend({ | |
model: null, | |
parent: null, | |
init() { | |
this._super(...arguments); | |
if (this.get('parent')) { | |
this.get('parent').register(this); | |
} | |
} | |
}); |
This file contains hidden or 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'; | |
export default Ember.Component.extend({ | |
children: null, | |
init() { | |
this._super(...arguments); | |
this.set('children', []); | |
}, | |
registerWithParent(child) { | |
Ember.run.later(function() { | |
this.get('children').addObject(child); | |
}, 1000); | |
} | |
}); |
This file contains hidden or 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 childObject = Ember.Object.extend({ | |
name: null | |
}); | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
models: null, | |
init() { | |
this._super(...arguments); | |
this.set('models', [ | |
childObject.create({ name: 'Child 1' }), | |
childObject.create({ name: 'Child 2' }), | |
childObject.create({ name: 'Child 3' }) | |
]); | |
} | |
}); |
This file contains hidden or 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.10.5", | |
"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.0", | |
"ember-data": "2.8.0", | |
"ember-template-compiler": "2.8.0", | |
"ember-testing": "2.8.0" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment