Skip to content

Instantly share code, notes, and snippets.

@jakecraige
Last active August 29, 2015 14:03
Show Gist options
  • Save jakecraige/aadceb03e7502e89b6d5 to your computer and use it in GitHub Desktop.
Save jakecraige/aadceb03e7502e89b6d5 to your computer and use it in GitHub Desktop.
<h2 id='title'>Welcome to Ember.js</h2>
<form {{action 'createTodo' on='submit'}}>
{{input value=todo.name}}
</form>
<ul>
{{#each}}
<li>
{{name}}
</li>
{{/each}}
</li>
import Ember from 'ember';
export default Ember.ArrayController.extend({
freshTodo: function() {
this.set('todo', this.store.createRecord('todo'));
}.on('init'),
actions: {
createTodo: function() {
this.get('todo').store.save().then(function(todo) {
this.get('model').pushObject(todo);
this.freshTodo();
}.bind(this));
}
}
});
import Ember from 'ember';
export default Ember.Route.extend({
model: function() {
return this.store.findQuery('todo', {});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment