Filtering our content

Now we have control over our people rows and some filter controls in our view, we need to make our filters work. We are already filtering by our isActive key, so the radio buttons will be the first to be wired up. We already have the value in a Boolean form for both the radio buttons values and the key we will be filtering by. For this filter to work, we need to compare the isActive key with the radio button's value.

  • If the filterUserState value is true, show users where isActive is true
  • If the filterUserState value is false, however, only show users where their isActive value is false as well

This can be written in one line by comparing the two variables:

      filterRow(person) { return (this.filterUserState === person.isActive); ...

Get Vue.js 2.x by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.