JSFiddle - React, Tailwind, and code Playground
HTML
<div ng-app='myApp' ng-controller="Controller">
<div ng-init="indiansCount = 0" ng-repeat="emp in records">
<b>Can Vote :</b><br>
<b>Indians :</b> {{getIndiansCount(emp.country, indiansCount)}}
<div ng-repeat="empl in emp">
{{empl.country}}<br>
{{empl.employee.name}}<br>
{{empl.employee.canVote}}
<hr>
</div>
</div>
<div> Total Indians : {{records | Indian}} </div>
<div> Total Can Vote : {{records | CanVote}} </div>
<div> Total Can Vote : {{records | IndianCanVote}} </div>
</div>
JavaScript
var app = angular.module('myApp', []);
app.controller('Controller', function ($scope) {
$scope.records = {
"Employee 1" : [{
country:"Indian",
employee: {canVote : true, name: "Manu"}
},
{
country:"Indian",
employee: {canVote : false, name: "Danny"}
},
{
country:"American",
employee: {canVote : true, name: "Sunny"}
}],
"Employee 2" : [{
country:"Indian",
employee: {canVote : true, name: "Mary"}
}]
};
$scope.getIndiansCount = function(country, count)
{
if(country === "Indian")
{
count++;
}
return count;
};
});
app.filter("Indian", function() {
return function(records) {
var totalIndianCount = 0;
angular.forEach(records, function(emp, empKey) {
angular.forEach(emp, function(oneEmp, oneEmpKey) {
if (oneEmp.country === "Indian") {
totalIndianCount += 1;
}
});
});
return totalIndianCount;
}
});
app.filter("CanVote", function() {
return function(records) {
var totalCanVote = 0;
angular.forEach(records, function(emp, empKey) {
angular.forEach(emp, function(oneEmp, oneEmpKey) {
if (oneEmp.employee.canVote) {
totalCanVote += 1;
}
});
});
return totalCanVote;
}
});
app.filter("IndianCanVote", function() {
return function(records) {
var totalCanVote = 0;
angular.forEach(records, function(emp, empKey) {
angular.forEach(emp,...