Created
June 2, 2017 02:34
Revisions
-
Subtletree created this gist
Jun 2, 2017 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ import Ember from 'ember'; export default Ember.Controller.extend({ appName: 'Ember Twiddle', arr: [{},{},{},{},{},{},{},{},{},{}], arrayLength: Ember.computed.alias('arr.length'), arrayObserver: Ember.observer('arr.length', function() { alert(this.get('arr.length')); }), actions: { add() { let newItem = {}; this.get('arr').splice(4, 0, newItem); }, remove(item) { this.get('arr').removeObject(item); } } }); 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ <h1>Welcome to {{appName}}</h1> {{#each arr as |item index|}} <p>item {{index}} <button {{action 'remove' item}}>x</button></p> {{/each}} Array length: {{arrayLength}} <button {{action 'add'}}>Add</button> 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ { "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" } }