Skip to content

Instantly share code, notes, and snippets.

@iamdtang
Last active March 25, 2016 01:16
Show Gist options
  • Save iamdtang/e272ff43506509213fdb to your computer and use it in GitHub Desktop.
Save iamdtang/e272ff43506509213fdb to your computer and use it in GitHub Desktop.
pushObject and todos
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
init() {
this.set('todos', ['todo 1', 'todo 2']);
},
actions: {
add() {
this.get('todos').pushObject('todo 3');
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
{{#each todos as |todo|}}
{{todo}}<br>
{{/each}}
<br>
<button onclick={{action 'add'}}>Add</button>
{
"version": "0.7.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.4.3/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.4.3/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.4.3/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment