New Twiddle
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
init() { | |
this._super(...arguments); | |
this.set('myArray', []); | |
}, | |
getNewItem() { | |
const items = this.get('items'); | |
return Math.floor(Math.random() * 100); | |
}, | |
myItems1: Ember.computed('myArray', function() { | |
return this.get('myArray').join(', '); | |
}), | |
myItems2: Ember.computed('myArray.[]', function() { | |
return this.get('myArray').join(', '); | |
}), | |
actions: { | |
addItemToArray() { | |
this.get('myArray').addObject(this.getNewItem()); | |
}, | |
addItemAndReplaceArray() { | |
const myArray = this.get('myArray'); | |
const newArray = myArray.concat([this.getNewItem()]); | |
this.set('myArray', newArray); | |
}, | |
}, | |
}); |
body { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
} |
{ | |
"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" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment