I am using the following code to try and generate a list showing the count of each item in the letters list within an AngularJS controller:
$scope.letters = ['a','b','c'];
$scope.letterdata = ['a','b','a','c','b','a'];
$scope.counts = $scope.letters.map(function (x) {
$scope.letterdata.filter(function (y) {
return (x == y);
}).length;
});
I would like to get [3,2,1] as the output, but this is showing as [null,null,null].