[Vuejs]-Filtering js array with underscore.js

0👍

I am not sure what you want to accomplish, just shorten your code first. Secondaly, You do not need lodash for this basic filter, you can use default filter to do this task.
Also there seems to be multiple toLowerCase() instead of toString().toLowerCase()

collection = _.filter(collection, function (element) {
                return element.cast.toString().toLowerCase().indexOf(this.scast.toString().toLowerCase()) != -1;
            });
            return collection;

Maybe this helps you, if not please edit the question so that we could understand it better what you want to accomplish and not this redundant code.

Just refactoring your code method

messageFiltering() {
            return movies.filter(movies, function (element) {
                return element.year.toString().toLowerCase().indexOf(this.syearfrom.toString().toLowerCase()) != -1 && element.title.toString().toLowerCase().indexOf(this.stitle.toString().toLowerCase()) != -1 && element.cast.toString().toLowerCase().indexOf(this.scast.toStringe().toLowerCase()) != -1;
            });
        }

Edit :
Try updating this line

<input v-on:click="messageFiltering" type="button" class="btn btn-info col-sm-12" value="Szukaj"/>

Ref

Leave a comment