Skip to content

Instantly share code, notes, and snippets.

@pzuraq
Created January 21, 2015 03:06
Show Gist options
  • Save pzuraq/4180624ac114ec58bbfb to your computer and use it in GitHub Desktop.
Save pzuraq/4180624ac114ec58bbfb to your computer and use it in GitHub Desktop.
// verses.js - controller
import Ember from 'ember';
import DS from 'ember-data';
export default Ember.ObjectController.extend({
actions: {
getAnotherVerse: function() {
// Here you need to understand a little bit about promises. A promise is
// asynchronous, so in you need to use .then() to get the value of the
// promise that is returned.
var controller = this;
this.store.find('verse', '0').then(function(verse) {
controller.set('model', verse);
});
}
}
});
// verses.js - router
import Ember from 'ember';
export default Ember.Route.extend({
model: function() {
// You need to return the model in this function. In this case,
// you are returning a promise that resolves to your model.
return this.store.find('verse', '0');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment