Function
map (dependentKey, callback) Ember.ComputedProperty public
Module: | @ember/object |
---|
Defined in packages/ember-runtime/lib/computed/reduce_computed_macros.js:181
import { map } from '@ember/object/computed';
- dependentKey
- String
- callback
- Function
- returns
- Ember.ComputedProperty
- an array mapped via the callback
Returns an array mapped via the callback
The callback method you provide should have the following signature. item
is the current item in the iteration. index
is the integer index of the current item in the iteration.
function(item, index);
Example
let Hamster = Ember.Object.extend({ excitingChores: Ember.computed.map('chores', function(chore, index) { return chore.toUpperCase() + '!'; }) }); let hamster = Hamster.create({ chores: ['clean', 'write more unit tests'] }); hamster.get('excitingChores'); // ['CLEAN!', 'WRITE MORE UNIT TESTS!']
© 2020 Yehuda Katz, Tom Dale and Ember.js contributors
Licensed under the MIT License.
https://api.emberjs.com/ember/2.18/functions/@ember%2Fobject%2Fcomputed/map