Last active
May 22, 2019 05:21
-
-
Save nolman/0444a33eabe6fe2c4b76b173176c0451 to your computer and use it in GitHub Desktop.
New Twiddle
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'; | |
import { computed, set } from '@ember/object'; | |
import { A } from '@ember/array'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
init() { | |
this.set('data', [{value: '123'}]); | |
}, | |
arrayComputed: computed('data.[].{value}', function() { | |
return this.get('data').length; | |
}), | |
viaLength: computed('data.length', function() { | |
return this.get('data').length; | |
}), | |
eachComputed: computed('data.@each.{value}', function() { | |
return this.get('data').length; | |
}), | |
hashComputed: computed('data.{0,1,2}', function() { | |
return this.get('data').length; | |
}), | |
actions: { | |
addItemViaSet() { | |
this.get('data').set(1, {value: 'abc'}); | |
}, | |
changeValueAtIndex1() { | |
set(this.get('data')[1],'value', 'DEF'); | |
}, | |
notifyPropertyChange() { | |
this.notifyPropertyChange('data') | |
}, | |
addItemViaPush() { | |
this.get('data').pushObject({value: '442'}); | |
}, | |
reset() { | |
this.set('data', A([{value: '123'}])); | |
}, | |
}, | |
}); |
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.15.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.4.3", | |
"ember-template-compiler": "3.4.3", | |
"ember-testing": "3.4.3" | |
}, | |
"addons": { | |
"ember-data": "3.4.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment