maria maria - 1 year ago 79
AngularJS Question

Angularjs Split array by object result

I have a array with objects like this:

__v: 0,
_id: "5835ced6ffb2476119a597b9",
castvote: 1,
time: "2016-11-23T17:16:06.676Z",
userid: "57e0fa234f243f0710043f8f"

How can I make a new array that would filter them by the
- like an array containing the objects where
is 1, and one where
is 2?

Answer Source

You can do this in controller using $filter,

$scope.castvoteOne = $filter('filter')($scope.results, {castvote: 1});
$scope.castvoteTwo = $filter('filter')($scope.results, {castvote: 2});


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download