angular.Array.count

Description

Determines the number of elements in an array. Optionally it will count only those elements for which the condition evaluates to true.

Note: this function is used to augment the Array type in angular expressions. See angular.Array for more info.

Dependencies

Usage

angular.Array.count(array[, condition]);

Parameters

Returns

{number}

Number of elements in the array (for which the condition evaluates to true).

Example

<pre ng:init="items = [{name:'knife', points:1}, {name:'fork', points:3}, {name:'spoon', points:1}]"></pre> <ul> <li ng:repeat="item in items"> {{item.name}}: points= <input type="text" name="item.points"/> <!-- id="item{{$index}} --> </li> </ul> <p>Number of items which have one point: <em>{{ items.$count('points==1') }}</em></p> <p>Number of items which have more than one point: <em>{{items.$count('points&gt;1')}}</em></p>