Syntax
1{{ value | sum }}2{{ value | sum:"amount" }}3{{ value | sum:"details.amount" }}
Usage
- Without a parameter, numeric array items are added.
- Pass a quoted property path to add values from object items. Dotted paths select nested own properties.
- Finite numbers and nonblank numeric strings are included. Missing properties, blank strings, nonnumeric values, and infinities are ignored.
- An empty array returns
0.
Examples
Open in Playground| Data | 1{2 "values": [3 10,4 "2.5",5 "",6 "none"7 ]8}
|
|---|
| Template | 1{{ values | sum }}
|
|---|
| Output | 112.5
|
|---|
Open in Playground| Data | 1{2 "items": [3 {4 "amount": 105 },6 {7 "amount": "2.5"8 },9 {}10 ]11}
|
|---|
| Template | 1{{ items | sum:"amount" }}
|
|---|
| Output | 112.5
|
|---|