Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save danielspaniel/bc7b009ab75f10986cb2b8838209f606 to your computer and use it in GitHub Desktop.
Save danielspaniel/bc7b009ab75f10986cb2b8838209f606 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Model from "ember-data/model";
import attr from "ember-data/attr";
import { belongsTo, hasMany } from "ember-data/relationships";
export default Model.extend({
changeTracker: { auto: true },
project: belongsTo()
});
import Model from "ember-data/model";
import attr from "ember-data/attr";
import { belongsTo, hasMany } from "ember-data/relationships";
export default Model.extend({
changeTracker: { auto: true },
orders: hasMany()
});
import Ember from 'ember';
export default Ember.Route.extend({
beforeModel() {
let data = {
data: {
id: 1,
type: 'project'
}
};
this.store.pushPayload(data);
},
model() {
let project = this.store.peekRecord('project', 1);
let order = Ember.run(() =>this.store.createRecord('order', { project }));
//order.saveChanges();
//order.startTrack();
return order.savedTrackerValue('project');
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
Saved Tracker Value: --&gt;{{model}}&lt;--
<br>
<br>
{
"version": "0.12.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.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-data": "2.12.1",
"ember-data-change-tracker": "0.5.6"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment