-
-
Save BenjaminBeck/ae2df27ab912c26c85a4faab6d58d10b to your computer and use it in GitHub Desktop.
New Twiddle
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.Controller.extend({ | |
| appName: 'Ember Twiddle', | |
| parent: Ember.computed(function() { | |
| var parent = this.get('store').createRecord('parent', { | |
| id: 'Edna', | |
| name: 'Edna' | |
| }); | |
| return parent; | |
| }) | |
| }); |
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.Controller.extend({ | |
| parents: Ember.computed(function() { | |
| return this.get('store').peekAll('parent'); | |
| }), | |
| parent: Ember.computed.alias('model'), | |
| sons: Ember.computed.alias('parent.sons'), | |
| son: Ember.computed.alias('parent.firstSon'), | |
| }); |
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 Model from 'ember-data/model'; | |
| import attr from 'ember-data/attr'; | |
| import { belongsTo, hasMany } from 'ember-data/relationships'; | |
| export default Model.extend({ | |
| type: attr('string'), | |
| name: attr('string'), | |
| parent: belongsTo('parent', {async: false}), | |
| toy: belongsTo('toy', {async: false}) | |
| }); |
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 Model from 'ember-data/model'; | |
| import attr from 'ember-data/attr'; | |
| import { belongsTo, hasMany } from 'ember-data/relationships'; | |
| import Ember from 'ember'; | |
| export default Model.extend({ | |
| name: attr('string'), | |
| children: hasMany('child', {async: true}), | |
| sons: Ember.computed.filterBy('children', 'type', 'son'), | |
| firstSon: Ember.computed.alias('sons.firstObject') | |
| }); |
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 Model from 'ember-data/model'; | |
| import attr from 'ember-data/attr'; | |
| import { belongsTo, hasMany } from 'ember-data/relationships'; | |
| export default Model.extend({ | |
| type: attr('string') | |
| }); |
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 EmberRouter from '@ember/routing/router'; | |
| import config from './config/environment'; | |
| const Router = EmberRouter.extend({ | |
| location: 'none', | |
| rootURL: config.rootURL | |
| }); | |
| Router.map(function() { | |
| this.route('parent', {path:'parent/:parent_id'}); | |
| }); | |
| export default Router; |
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.Route.extend({ | |
| setupController: function(controller, model) { | |
| this._super(...arguments); | |
| var toy = this.get('store').createRecord('toy', { | |
| type: 'latte' | |
| }); | |
| this.get('store').createRecord('child', | |
| {parent: model, type: 'son', toy: toy, | |
| name: 'Tyler'}); | |
| } | |
| }); |
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.14.1", | |
| "EmberENV": { | |
| "FEATURES": {} | |
| }, | |
| "options": { | |
| "use_pods": false, | |
| "enable-testing": false | |
| }, | |
| "dependencies": { | |
| "jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
| "ember": "3.4.3", | |
| "ember-template-compiler": "3.4.3", | |
| "ember-testing": "3.4.3" | |
| }, | |
| "addons": { | |
| "ember-data": "3.4.2" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment