javascript - Angular inline Filter "controller side" -
i have selection of categories returned after selection correctly html view {{cat}} display comics if comics selected list
$scope.selectcategory = function (newcategory) { console.log(newcategory); $scope.cat = newcategory; selectedcategory = newcategory; $scope.selectedpage = 1; }
however want filter array of objects category controller side not usual inline filters in view i'm aware of
if manually add category in example below comics
$scope.edition_products = $filter('filter') ( $scope.filtereditems, {approved: true, category: "comics"});
only category comics approved true returned filter works
but how make dynamic injecting inline $scope.cat
e.g.
$scope.edition_products = $filter('filter') ( $scope.filtereditems, {approved: true, [$scope.cat]}
note not work
filter in controller doesn't automatically trigger. have run filter each time select category, in selectcategory
function have re-run filter
such
$scope.selectcategory = function (newcategory) { console.log(newcategory); $scope.cat = newcategory; selectedcategory = newcategory; $scope.selectedpage = 1; $scope.edition_products = $filter('filter')($scope.filtereditems {approved: true, category: $scope.cat}); }
doing filter data each time change category.
Comments
Post a Comment