Function
sum (dependentKey) ComputedProperty public
Module:
@ember/object
Defined in packages/@ember/object/lib/computed/reduce_computed_macros.ts:76
Available since v1.4.0
import { sum } from '@ember/object/computed'; |
- dependentKey
- String
- returns
- ComputedProperty
- computes the sum of all values in the dependentKey's array
A computed property that returns the sum of the values in the dependent array.
Example:
1 2 3 4 5 6 7 8 9 10 11 |
import { sum } from '@ember/object/computed'; class Invoice { lineItems = [1.00, 2.50, 9.99]; @sum('lineItems') total; } let invoice = new Invoice(); invoice.total; // 13.49 |