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

add onBeforeSelect callback #1075

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use typical promise-handling convention
jnelson committed Jul 9, 2015
commit bb8bfd0abd0b660eb4f4e5a58b2a4192f736a3fc
4 changes: 2 additions & 2 deletions src/uiSelectController.js
Original file line number Diff line number Diff line change
@@ -312,8 +312,8 @@ uis.controller('uiSelectCtrl',
if (angular.isDefined(onBeforeSelectResult)) {
if (!onBeforeSelectResult) {
return; // abort the selection in case of deliberate falsey result
} else if (angular.isDefined(onBeforeSelectResult.promise)) {
onBeforeSelectResult.promise.then(completeSelection);
} else if (angular.isFunction(onBeforeSelectResult.then)) {
onBeforeSelectResult.then(completeSelection);
} else {
completeSelection();
}
4 changes: 2 additions & 2 deletions test/select.spec.js
Original file line number Diff line number Diff line change
@@ -995,7 +995,7 @@ describe('ui-select tests', function() {
order.push('onBeforeSelectFn');
deferred.resolve(order);
});
return deferred;
return deferred.promise;
};
scope.onSelectFn = function ($item, $model, $label) {
order.push('onSelectFn');
@@ -1055,7 +1055,7 @@ describe('ui-select tests', function() {
$timeout(function () {
deferred.reject();
});
return deferred;
return deferred.promise;
};
scope.onSelectFn = function ($item, $model, $label) {
scope.$item = $item;