djett41 / ionic-filter-bar

Filter Bar plugin for the Ionic Framework
MIT License
362 stars 112 forks source link

Add promise-able search function (fixes #34, #35) #58

Open ace-han opened 9 years ago

ace-han commented 9 years ago

Based on #35 , make the return value from search function promise-able

balicekt commented 9 years ago

Hey, very nice!

I have just one question. I want to show loader before call my API but it doesn't work. My code looks like this:

            search: function (filterText) {
                $scope.showLoading = true;
                console.log('search');
                var deferred = $q.defer();
                $timeout(function (){
                    //$scope.searchLoading = false;
                        deferred.resolve(AdversaryLists.initSearchList(data.list)); 
                });
                return deferred.promise;
            },

in my console I can see 'search' is logged immediately but the property showLoading is true after deffered.resolve is called. Absolutely don't understand why :( Thanks for any help

ace-han commented 9 years ago

@balicekt It's likely a typo. Just replace $scope.searchLoading = false; with $scope.showLoading = false;`

balicekt commented 9 years ago

@ace-han thank you for you answer. searchLoading = false is commented it not about it. It is about $scope.showLoading = true; because $scope.showLoading get true after deferred.resolve is called. It means is for nothing because I need to show spinner before it finish :( It means the loading spinner is never shown because it get false in the same time like get true (when I change scope.searchLoading to scope.showLoading and uncomment this line)