javascript - Filtering based on properties of objects within array using $filter -


Assume the following data:

  var roster = [{id: 1, participાનો] True: person: {printName: 'Larry'}}, {id: 2, participated in: wrong, person: {printName: 'curly'}}, {id: 3, present: true, person: {printName : 'Moe'}}];  

I am trying to find the count of objects in the array where the present is true. I have tried the following:

rosters.html:

  {{roster | Filters: {Attendance: true}). Length}}   

Roster-Controller Js:

  Check Incount: Function () {$ Filter ('Filter') $ Scope.roster, attended.true). Length; }  

The HTML filter works as expected, returns 2 in this example. However, there is an error reference error in the function version: the variable can not be found: present . I think that something trivial that I missed in the ceremony, but I do not know what it is.

Use an object as expression:

  $ Filter ('Filter') ($ scope.roster, {attend: true}). Length;  

Comments

Popular posts from this blog

c# - SignalR: "Protocol error: Unknown transport." when navigating to hub -

class - Kivy: how to instantiate a dynamic classes in python -

python - mayavi mapping a discrete colorbar on a surface -