Skip to content

Instantly share code, notes, and snippets.

@pablohpsilva
Created July 15, 2016 22:29
Show Gist options
  • Save pablohpsilva/2f566381c89b33677759debb71a4c5bf to your computer and use it in GitHub Desktop.
Save pablohpsilva/2f566381c89b33677759debb71a4c5bf to your computer and use it in GitHub Desktop.
<style>
</style>
<template>
<div class="" v-for="item in list | formatResult filter">
{{item}}
</div>
</template>
<script type="text/babel">
export default {
data() {
list: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
filter: []
},
methods: {
createFilterStructure(id, args, func) {
return {id, args, func};
},
addFilterFunction(id, args, func) {
this.filter.push(this.createFilterStructure(id, args, func));
}
},
ready() {
this.addFilterFunction('odd', [], (list) => { return list.filter((el) => {return (el % 2 !== 0)})});
this.addFilterFunction('greaterThan5', [], (list) => { return list.filter((el) => {return (el > 5)})});
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment