I have a scope variable that looks as follows:
$scope.people = [
{'id':'1' ,'name':'John','category':'m'},
{'id':'2', 'name':'Jack','category':'m'},
{'id':'3','name':'Mark','category':'m'},
{'id':'4','name':'Ernie','category':'m'},
{'id':'5','name':'Jane','category':'w'},
{'id':'6','name':'Jill','category':'w'},
{'id':'7','name':'Betty','category':'w'},
{'id':'8','name':'Mary','category':'w'}
];
This is a sample scope variable i created for the puspose of this problem. But i will be getting this data from a service. What i would like to achieve is, how do i filter this scope variable in to different variables from within the controller?
For example, i want to make 2 new scopes as follows from the given scope:
$scope.men = [
{'id':'1' ,'name':'John','category':'m'},
{'id':'2', 'name':'Jack','category':'m'},
{'id':'3','name':'Mark','category':'m'},
{'id':'4','name':'Ernie','category':'m'}
];
$scope.women = [
{'id':'5','name':'Jane','category':'w'},
{'id':'6','name':'Jill','category':'w'},
{'id':'7','name':'Betty','category':'w'},
{'id':'8','name':'Mary','category':'w'}
];
How do i achieve this? Any knowledge will be very helpful