ionic-filter-bar icon indicating copy to clipboard operation
ionic-filter-bar copied to clipboard

expression function is not receiving filterText param as in docs

Open vcalvello opened this issue 10 years ago • 6 comments

vcalvello avatar Sep 03 '15 14:09 vcalvello

Can you post the code you are using in your call to filterBar? If you take a look at the unit test, the following expression returns the filterText as the first arg. I just doubled checked and verified that its returning.

expression: function (filterText, value, index, array) {
    return value.name.length >= 8 || value.description.indexOf(filterText) !== -1;
}

djett41 avatar Sep 03 '15 16:09 djett41

vm.filterBarInstance = $ionicFilterBar.show({
    items: vm.gamesData,
    expression: function (filterText, value, index, array) {
        console.log(arguments.length);
        console.log(arguments);
        console.log(filterText);
        return true;
        //return value.game.name.indexOf(filterText) !== -1;
    },
    update: function (filteredItems, filterText) {
       vm.gamesData = filteredItems;
    }
});

and the console output

3
[Object, 1, Array[5]]
Object {game: Object, extra: Object, $$hashKey: "object:52"}

vcalvello avatar Sep 03 '15 18:09 vcalvello

@vcalvello I am not able to see what your seeing.. when I add the exact same expression to the demo app in this repo, I get the following log for arguments when searching for "my search"

["my search", Object, 1998, Array[1999]]

Are you on the latest version? Pull down the demo, verify that you see what I'm seeing, then either try to see what the difference between your version and the demo version, or see if you can put a codepen together so I can look at it. Thanks!

djett41 avatar Sep 05 '15 06:09 djett41

@djett41 Seems to be something with the published component version. Everything fine using the repo src

vcalvello avatar Sep 08 '15 14:09 vcalvello

@vcalvello Which version are you on? I tried both the unminified and minified dist but am seeing the correct behavior. Perhaps there was an issue with a previous version? Can you verify you're on the latest version? If you are still seeing the issue, If you can put together a codepen that I can replicate the issue I can look into it thanks!!

djett41 avatar Sep 12 '15 16:09 djett41

I can confirm this problem. The code in source is difference from latest release and using the source code everything works fine.

yang-zhang-syd avatar Feb 24 '16 12:02 yang-zhang-syd