Created
March 28, 2016 02:09
-
-
Save derrickshowers/0d78187fb472bd6858a6 to your computer and use it in GitHub Desktop.
Ember Arrays
This file contains 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: 'Ember Arrays', | |
foo: [], | |
bar: Ember.computed('foo', function() { | |
console.log('bar called'); | |
}), | |
baz: Ember.computed('foo.[]', function() { | |
console.log('baz called'); | |
}), | |
actions: { | |
addObject() { | |
this.get('foo').pushObject({}); | |
console.log(this.get('foo.length')); | |
}, | |
addObjectJS() { | |
let foo = this.get('foo'); | |
foo.push({}); | |
console.log(foo === this.get('foo')); | |
this.set('foo', foo); | |
console.log(this.get('foo')); | |
}, | |
replaceObject() { | |
this.set('foo', []); | |
}, | |
outputFoo() { | |
console.dir(this.get('foo')); | |
} | |
} | |
}); |
This file contains 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.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": "release", | |
"ember-data": "release", | |
"ember-template-compiler": "release" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment