Last active
May 23, 2017 19:50
Revisions
-
offirgolan revised this gist
May 19, 2017 . 2 changed files with 20 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 @@ -1,15 +1,22 @@ import Ember from 'ember'; import { array } from 'ember-awesome-macros'; import computed from 'ember-macro-helpers/computed'; export default Ember.Controller.extend({ appName: 'Ember Twiddle', array: [{ someProp: 1 }], prop: 'someProp', mappedArray: computed(array.mapBy('array', 'prop'), (array) => array), init() { this._super(...arguments); this.set('dependents', this.mappedArray._dependentKeys.join(', ')); }, actions: { addItem() { this.get('array').pushObject({ someProp: 1 }); } } }); This file contains hidden or 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 @@ -5,4 +5,13 @@ <br> <br> array.mapBy Dependents: {{dependents}} <br> <br> array: {{array.length}} <br> mappedArray: {{mappedArray.length}} <br> <br> <button {{action 'addItem'}}>Add Item</button> -
offirgolan created this gist
May 19, 2017 .There are no files selected for viewing
This file contains hidden or 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,15 @@ import Ember from 'ember'; import { array } from 'ember-awesome-macros'; export default Ember.Controller.extend({ appName: 'Ember Twiddle', array: [], prop: 'someProp', mappedArray: array.mapBy('array', 'prop'), init() { this._super(...arguments); this.set('depndents', this.mappedArray._dependentKeys.join(', ')); } }); This file contains hidden or 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> <br> <br> {{outlet}} <br> <br> array.mapBy Dependents: {{depndents}} This file contains hidden or 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,21 @@ { "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", "ember-awesome-macros": "0.36.0", "ember-macro-helpers": "0.14.1" } }