Last active
June 12, 2018 11:41
-
-
Save jbandura/5a75a631eabf0112b980af323937ee23 to your computer and use it in GitHub Desktop.
model contains test
This file contains 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', | |
johnIncluded: Ember.computed('models.[]', 'johnModel', function() { | |
return this.get('models').contains(this.get('johnModel')); | |
}), | |
init() { | |
this._super(...arguments); | |
const johnModel = this.store.createRecord('test-model', { name: 'John' }); | |
this.set('johnModel', johnModel); | |
const models = [ | |
johnModel, | |
this.store.createRecord('test-model', { name: 'Jane' }), | |
this.store.createRecord('test-model', { name: 'Chuck' }), | |
]; | |
this.set('models', models); | |
}, | |
actions: { | |
removeJohn() { | |
const newModels = this.get('models') | |
.filter(item => item !== this.get('johnModel')); | |
this.set('models', newModels); | |
}, | |
} | |
}); |
This file contains 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({ | |
name: attr('string'), | |
}); |
This file contains 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": "2.18.2", | |
"ember-template-compiler": "2.18.2", | |
"ember-testing": "2.18.2" | |
}, | |
"addons": { | |
"ember-data": "2.18.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment