Ember.computed.mapBy()

mapBy (dependentKey, propertyKey) Ember.ComputedPropertypublic

Defined in packages/ember-runtime/lib/computed/reduce_computed_macros.js:208

Returns an array mapped to the specified key.

let Person = Ember.Object.extend({
  childAges: Ember.computed.mapBy('children', 'age')
});

let lordByron = Person.create({ children: [] });

lordByron.get('childAges'); // []
lordByron.get('children').pushObject({ name: 'Augusta Ada Byron', age: 7 });
lordByron.get('childAges'); // [7]
lordByron.get('children').pushObjects([{
  name: 'Allegra Byron',
  age: 5
}, {
  name: 'Elizabeth Medora Leigh',
  age: 8
}]);
lordByron.get('childAges'); // [7, 5, 8]

Parameters:

dependentKey String
propertyKey String

Returns:

Ember.ComputedProperty
an array mapped to the specified key
doc_EmberJs
2016-11-30 16:51:16
Comments
Leave a Comment

Please login to continue.