I saw this code in Angular Material web site :
function querySearch (query) {
var results = query ? self.states.filter( createFilterFor(query) ) : self.states,
deferred;
if (self.simulateQuery) {
deferred = $q.defer();
$timeout(function () { deferred.resolve( results ); }, Math.random() * 1000, false);
return deferred.promise;
} else {
return results;
}
}
Can anyone explain whats happening here ?
if query is not null we call the filter otherwise we return the states and what is that ",deffered" part ?
defered has not created yet and we can't return multiple values either!
So what is the explanation for this code ?
The code is here: https://material.angularjs.org/latest/demo/autocomplete The first one (Basic Usage)