I have the following angular object in my controller
$scope.students = [{:id => 1, :state => 'active'}, {:id => 2, :state => 'suspended'}]
How can i get id of all students whose state is active? Can anyone please help me with this?
There is multiple ways but the easiest I can think of is adding an activeStudent function in your scope, something like this:
$scope.activeStudent = function(){
return _.filter($scope.students, function(s){
return s.state == "active";
});
}
and in your views you would use activeStudent() in your binding.