Assuming the following data:
var roster = [
{
id: 1,
attended: true,
person: {printName: 'Larry'}},
{
id: 2,
attended: false,
person: {printName: 'Curly'}},
{
id: 3,
attended: true,
person: {printName: 'Moe'}}];
I am trying to find the count of objects in the array where attended is true. I have tried the following:
rosters.html:
{{ (roster | filter:{attended:true} ).length }}
rosters-controller.js:
checkedInCount: function() {
return $filter('filter')($scope.roster, attended.true).length;
}
The html filter works as expected, returning 2 in this instance. However, the function version encounters the error ReferenceError: Can't find variable: attended
. I assume that there is something trivial that I've missed in the function, but I am not sure what it is.
expression
argument. After seeing @tasseKATT's answer, it totally makes sense now. – The DIMM Reaper Oct 17 '14 at 16:41