Guest User

Untitled

a guest
Oct 23rd, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. import Ember from 'ember';
  2.  
  3. export default Ember.Component.extend({
  4. _array: [],
  5.  
  6. array: Ember.computed('_array',{
  7. get(key) { return this.get('_array'); },
  8. set(key,value) { this.set('_array', value); }
  9. }),
  10.  
  11. isEmpty: Ember.computed('array', function() {
  12. // Here, this.get('array') returns undefined. Why?
  13. return this.get('array').length;
  14. }),
  15.  
  16. actions: {
  17. addNew() {
  18. this.get('array').push(Date.now());
  19. }
  20. },
  21.  
  22. init() {
  23. this._super(...arguments);
  24.  
  25. this.set('array', [1,2,3]);
  26.  
  27. // If I call this.get('array') here, undefined is returned even though I just set it.
  28. },
  29. });
Add Comment
Please, Sign In to add comment