AngularJS: Filter Length
HTML
<div ng-controller="YourCtrl">
<input type="text" ng-model="search.description" />
<br />
<br />
<input type="text" ng-model="search.severity" />
<br />
<br />
<input type="text" ng-model="search.duration" />
<br />
<br />
<p>Number of Critical Events: {{(eventsData | filter:'Critical').length}}</p>
<p>Number of Warning Events: {{(eventsData | filter:'Warning').length}}</p>
<p>Number of Ok Events: {{(eventsData | filter:'ok').length}}</p>
<br />
<div ng-repeat="eventData in eventsData | filter:search:strict">
<div> {{eventData.severity}} </div>
<div> {{eventData.description}} </div>
<div> {{eventData.duration}} </div>
</div>
</div>
JavaScript
'use strict';
var app = angular.module('myApp', []);
app.controller('YourCtrl', ['$scope', function($scope) {
$scope.eventsData = [
{
'severity': 'Critical',
'description': 'content1',
'duration': 1
}, {
'severity': 'Warning',
'description': 'content2',
'duration': 2
}, {
'severity': 'ok',
'description': 'content3',
'duration': 3
}, {
'severity': 'Warning',
'description': 'content2',
'duration': 2
}, {
'severity': 'ok',
'description': 'content3',
'duration': 3
}
];
}]);