angular-filter icon indicating copy to clipboard operation
angular-filter copied to clipboard

Added average filter to math module

Open benbakhar opened this issue 9 years ago • 4 comments

updated readme and added tests as well.

benbakhar avatar Oct 11 '14 19:10 benbakhar

Hi @benbakhar, take a look on this example, or see: jsbin

 $scope.nums = [1,2,3,4,5,6,7,8,10];
 $scope.scores = [
    { name: 'Dan', score: 80 },
    { name: 'Edd', score: 90 },
    { name: 'Edi', score: 40 },
    { name: 'Ari', score: 87 },
    { name: 'Tod', score: 99 }
  ];
example1:
<p>{{ (nums | sum) / nums.length }}</p> 
example2: <!-- your TODO :) -->
<p>{{ ( scores | map: 'score' | sum ) / scores.length }}</p>

Thx for the PR, let me know what do you think...

a8m avatar Oct 13 '14 17:10 a8m

Hey man, i updated the filter according your second example. make more sense this way gn :)

benbakhar avatar Oct 14 '14 22:10 benbakhar

Hey, I think this filter would be useful rather than to add a division...

Adriien-M avatar Dec 24 '14 09:12 Adriien-M

Yes, this would be a helpful addition to this already awesome library.

Delapouite avatar Jan 15 '15 11:01 Delapouite