I have a simple ng-repeat:
<li ng-repeat="country in getCountryGroups()">
{{country.name}}
</li>
I am trying to only display records if a bool value is true:
My controller:
$scope.countries = [
{name: 'France', population: 63.1, visited: true},
{name: 'Spain', population: 23.5, visited: true},
{name: 'Greece', population: 44.6, visited: true},
{name: 'United Kingdom', population: 61.8, visited: false}
];
$scope.getCountryGroups = function () {
var groupArrayNew = [];
angular.forEach($scope.countries, function (item, idx) {
if (groupArrayNew.indexOf(item.visited) == -1)
groupArrayNew.push(item.visited)
});
return groupArrayNew.sort();
}
However nothing is displayed on the front end.