(fix) Partial fix for md-contact-chips

Those fixes resolve the JavaScript errors, but the behavior is wrong;
the displayed results are delayed with respect to the search string.
md-contact-chips is expected to change (for the best) soon.
This commit is contained in:
Francis Lachapelle
2015-06-12 12:02:15 -04:00
parent ab38134ba9
commit 9f9cd68997
5 changed files with 28 additions and 14 deletions
@@ -40,10 +40,19 @@
* @return a promise of an array of matching User objects
*/
User.$filter = function(search) {
var param = {search: search};
if (!search)
return User.$q.when([]);
return User.$$resource.fetch(null, 'usersSearch', param).then(function(response) {
var deferred = User.$q.defer(),
param = {search: search};
if (!search) {
User.$users = [];
deferred.resolve(User.$users);
return deferred.promise;
}
if (angular.isUndefined(User.$users)) {
User.$users = [];
}
User.$$resource.fetch(null, 'usersSearch', param).then(function(response) {
var results = [];
angular.forEach(response.users, function(data) {
console.debug(JSON.stringify(data, undefined, 2));
@@ -51,8 +60,10 @@
results.push(user);
});
User.$users = results;
return results;
});
deferred.resolve(results);
}, deferred.reject);
return deferred.promise;
};
/**