Skip to content

Instantly share code, notes, and snippets.

@Epotignano
Last active September 12, 2015 15:00
Show Gist options
  • Save Epotignano/1f5cc14317ab6eee58b4 to your computer and use it in GitHub Desktop.
Save Epotignano/1f5cc14317ab6eee58b4 to your computer and use it in GitHub Desktop.
Using the array.some method for a filter.
.constant('geslachtOptions', [
{'value': 'M', 'label': 'Man'},
{'value' : 'V', 'label': 'Vrouw'},
{'value': 'O', 'label': 'Onbekend'}
])
.filter('geslachtFilter', function(geslachtOptions){
return function(input) {
if(input) {
var ind;
geslachtOptions.some(function(option, index){
ind = index;
return option.value == input
});
return geslachtOptions[ind].label;
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment