$scope.currentEvent = Object { item_id: "10535", name: "johnny", user_type: "1",category_id: "5"}, Object { item_id: "10534", name: "smith", user_type: "1",category_id: "6"}, Object { item_id: "10536", name: "Greg", user_type: "1",category_id: "7"};
$scope.users = Object { item_id: "11355", name: "mathew", user_type: "1",category_id: "7"}, Object { item_id: "10336", name: "Greg", user_type: "2",category_id: "7"}, Object { item_id: "10545", name: "powell", user_type: "1",category_id: "7"}, Object { item_id: "10456", name: "micheal", user_type: "3",category_id: "7"};
Require filtering based on user_type
Expected outcome = $scope.validUser = Object { item_id: "11355", name: "mathew", user_type: "1",category_id: "7"}, Object { item_id: "10545", name: "powell", user_type: "1",category_id: "7"};
My attempt: I attempted to use the code below, but it did not work for me
$scope.validUser = $scope.validUser.filter(function($scope.currentEvent){
return $scope.validUser.user_type === $scope.currentEvent.user_type;
});
Seeking guidance: How can we resolve this issue?
Furthermore, explain the process of filtering data in AngularJS.