Forked from chrishowes/controllers.application.js
Last active
November 29, 2016 02:03
-
-
Save chalda/fe516e801baf2a384dec30a09d798953 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: 'VisitDays' | |
}); |
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({ | |
firstName: attr("string"), | |
lastName: attr("string"), | |
visits: belongsTo("visit") | |
}); |
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({ | |
name: attr("string"), | |
users: hasMany("user"), | |
}); |
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'; | |
import config from './config/environment'; | |
const Router = Ember.Router.extend({ | |
location: 'none', | |
rootURL: config.rootURL | |
}); | |
Router.map(function() { | |
this.route('application', { path: '/' }, function(){ | |
this.route('visit', { path: '/:visit_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({ | |
beforeModel() { | |
var user1 = this.store.createRecord("user", { | |
id: 1, | |
firstName: "First", | |
lastName: "User", | |
}); | |
var user2 = this.store.createRecord("user", { | |
id: 2, | |
firstName: "Second", | |
lastName: "User", | |
}); | |
var user3 = this.store.createRecord("user", { | |
id: 3, | |
firstName: "Third", | |
lastName: "User", | |
}); | |
var user4 = this.store.createRecord("user", { | |
id: 4, | |
firstName: "Fourth", | |
lastName: "User", | |
}); | |
var user5 = this.store.createRecord("user", { | |
id: 5, | |
firstName: "Fifth", | |
lastName: "User", | |
}); | |
var visit1 = this.store.createRecord("visit", { | |
id: 1, | |
name: "Morning Visit", | |
users: [user1, user2, user3] | |
}); | |
var visit2 = this.store.createRecord("visit", { | |
id: 2, | |
name: "Afternoon Visit", | |
users: [user4, user5] | |
}); | |
}, | |
model() { | |
// var visits= ["foo", "bar"]; | |
var visits = this.store.peekAll('visit'); | |
// console.log(visits); | |
return visits; | |
// return { visits: visits}; | |
}, | |
controllerName: 'application', | |
setupController: function(controller, model) { | |
controller.set('model', model); | |
} | |
}); |
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'; | |
//this.route('edit', { path: '/:photo_id' }); | |
export default Ember.Route.extend({ | |
model() { | |
// var visits= ["foo", "bar"]; | |
var visits = this.store.peek('visit'); | |
// console.log(visits); | |
return visits; | |
// return { visits: visits}; | |
}, | |
}); |
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