[Vuejs]-Access component method from filter

0👍

With some^H lots of help, I now have the following:

filters: {
    roleFilter: function(users) {
        var self = this;

        if( this.roleFilterModel == 'all') {
            return users;
        }

        return users.filter(function(userData) {
            // Convert the passed in data to a component
            var user = new self.$options.components.user({
                data: userData
            });
            return user.hasRole(self.roleFilterModel);
        });
    }

It turns out that the filter runs on the data, before it is transformed into an component, so you need to do that manually to access component methods.

👤AlexW

Leave a comment