I want to filter an array in a controller but it returns nothing.
This is my controller:
.controller('cardsCtrl', function($scope, $sce, LearnCard, Category, $ionicModal, $stateParams, $filter) {
console.log("stateParam: " + $stateParams.catId);
// Get all LearnCards
$scope.learnCardsAll = LearnCard.query();
console.log("Before filtering");
console.log($scope.learnCardsAll); // is populated
$scope.learnCards = $filter('filter')($scope.learnCardsAll, { category: 1 });
learnCardsAll is populated as it should.
This is the structure of the elements: Console log
Maybe someone could help me?
$scope.learnCardsAllis populated, then$scope.learnCards = _.filter($scope.learnCardsAll, {category: 1});should work;