O'Reilly logo

The Majesty of Vue.js by Kostas Maniatis, Alex Kyriakidis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Custom filter

This is the most cumbersome part of this chapter. Assume we want to display only the famous stories (the ones with upvotes greater than 20). In order to achieve that we have to create a custom filter and apply it to filterBy. We are going to create a filter named famous which expects two parameters:

  • The array we want to filter
  • The bound which defines the amount of upvotes a story must have, in order to be considered as famous

The famous filter returns an array which contains only the objects that satisfy a condition.

If you can't keep up with this example don't worry, you will get it sooner or later, just keep reading..

<html> <head> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">     <title>Famous ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required