From 95d1768c7742e383bc8e9dda2279efd74b0b4131 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Wed, 24 Nov 2010 16:28:17 -0800 Subject: docs for angular.Array.sum --- src/apis.js | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/apis.js b/src/apis.js index 31d2b687..417670b5 100644 --- a/src/apis.js +++ b/src/apis.js @@ -76,6 +76,61 @@ var angularArray = { }); */ 'indexOf': indexOf, + + + /** + * @workInProgress + * @ngdoc function + * @name angular.Array.sum + * @function + * + * @description + * This function calculates the sum of all numbers in `array`. If the `expressions` is supplied, + * it is evaluated once for each element in `array` and then the sum of these values is returned. + * + * @param {Array} array The source array. + * @param {(string|function())=} expression Angular expression or a function to be evaluated for each + * element in `array`. The array element becomes the `this` during the evaluation. + * @returns {number} Sum of items in the array. + * + * @example +
| Qty | Description | Cost | Total | |
|---|---|---|---|---|
| + | + | + | {{item.qty * item.cost | currency}}+ | [X]+ | 
| add item+ | + | Total:+ | {{invoice.items.$sum('qty*cost') | currency}}+ |