Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit 97624a1

Browse files
committed
Add refresh function
See Expose $select.search for external / remote filtering #31
1 parent b1ffdb4 commit 97624a1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/select.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,16 @@ angular.module('ui.select', [])
149149
}
150150
};
151151

152+
ctrl.refresh = function(refreshAttr) {
153+
// Only works if the repeat expression (repeat.rhs) is a collection,
154+
// does not make sense with a promise
155+
if (refreshAttr !== undefined && _repeatRhsIsCollection) {
156+
$timeout(function() {
157+
$scope.$apply(refreshAttr);
158+
});
159+
}
160+
};
161+
152162
// When the user clicks on an item inside the dropdown list
153163
ctrl.select = function(item) {
154164
ctrl.selected = item;
@@ -326,6 +336,7 @@ angular.module('ui.select', [])
326336

327337
scope.$watch('$select.search', function() {
328338
$select.activeIndex = 0;
339+
$select.refresh(attrs.refresh);
329340
$select.populateItems();
330341
});
331342
};

0 commit comments

Comments
 (0)