Open ace-han opened 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
@balicekt It's likely a typo. Just replace $scope.searchLoading
= false; with $scope.showLoading
= false;`
@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)
Based on #35 , make the return value from
search
function promise-able