Created
August 8, 2014 17:43
-
-
Save gdoteof/94cc37b0cb9710f3d8cd to your computer and use it in GitHub Desktop.
filter examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="col-md-3 thumbnail-container magic-animate apositive" | |
ng-repeat="object in filteredpos = (container.objects | classIs: 1 | orderBy:'score' | scoreIs:'>':pos.lowest | scoreIs: '<': pos.highest)"> | |
<vmx-exemplar score="object.score" image="{{object.image}}" tyme="{{object.time}}" class="object.class_label"></vmx-exemplar> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vmxServices | |
.filter('includeParams',function(){ | |
return function(objects,toInclude){ | |
if (toInclude && toInclude instanceof Array){ | |
var tmpParams = {}; | |
for(var paramName in objects){ | |
if(!paramName){ continue; } | |
if(toInclude.indexOf(paramName) !== -1 || _.intersection(objects[paramName].group, toInclude).length){ | |
tmpParams[paramName] = objects[paramName]; | |
} | |
} | |
objects = tmpParams; | |
} | |
return objects; | |
}; | |
}); | |
vmxServices | |
.filter('modelNameContains',function(){ | |
return function(objects,name){ | |
if(!objects) { | |
return []; | |
} | |
return objects.filter( | |
function(elm){ return (elm.model.name !== "none") && !name || elm.model.name.indexOf(name) !== -1 } | |
); | |
}; | |
}); | |
vmxServices | |
.filter('scoreIs',function(){ | |
return function(objects,op,_score){ | |
var op_fun; | |
if(typeof _score === 'undefined' || _score === '') { | |
return objects; | |
} | |
switch(op){ | |
case '<': | |
case 'lt': op_fun = function(left,right){ return left < right; }; | |
break; | |
case '>': | |
case 'gt': op_fun = function(left,right){ return left > right; }; | |
} | |
return objects.filter(function(elm){ return op_fun(elm.score,_score); }); | |
}; | |
});; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment