javascript - Angular filter with OR operator -


i'm trying build filter range slider.

is possible set when range slider on 1 of positions show more 1 category?

with code below can filter using range, puts on filter first word , nothing more after or operator. can me?

$scope.filterrange = filterrange;  function filterrange() {     if (this.rangemodel == 1) {         $scope.categoryfilter = 'web' || 'ecommerce '; // that!     } else if(this.rangemodel == 2) {         $scope.categoryfilter = 'branding' || 'video'; // that!     } ; };  <div ng-repeat="project in projects | filter: {category: categoryfilter}"> 

i've see other post here, still not getting how can make happen. =(

thanks daniel, here's working solution:

$scope.projetos = [];  $scope.filtrorange = filtrorange;   function filtrorange() {     if (this.rangemodel == 1) {         $scope.categoryfilter = function(projeto) {         if (projeto.categoria === 'site institucional' || projeto.categoria === 'ecommerce') {             console.log('filtrando');             return projeto;                   }         };     } else if (this.rangemodel == 2) {         $scope.categoryfilter = function(projeto) {         if (projeto.categoria === 'branding' || projeto.categoria === 'email marketing') {             console.log('filtrando');             return projeto;                   }         };     }  }; 

you can create custom filter function so:

$scope.categoryfilter = function(project) {     if (this.rangemodel == 1) {         if (project.category === 'web' || project.category === 'ecommerce') {             return project;               }     } else if (this.rangemodel == 2) {         if (project.category === 'branding' || project.category === 'video') {                 return project;             }         }     } }; 

then html call function filter:

<div ng-repeat="project in projects | filter: categoryfilter"> 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -