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

Commit 9a40b6f

Browse files
homerjamuser378230
authored andcommitted
fix(uiSelectSort): update model on sort completion
Previously when order of selected items was changed, the ngModel value was not updated. This commit causes the model to be invalidated after a change to the order, triggering a refresh. Fixes #974 & Closes #1036
1 parent 152856d commit 9a40b6f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/uiSelectSortDirective.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
// Make multiple matches sortable
22
uis.directive('uiSelectSort', ['$timeout', 'uiSelectConfig', 'uiSelectMinErr', function($timeout, uiSelectConfig, uiSelectMinErr) {
33
return {
4-
require: '^^uiSelect',
5-
link: function(scope, element, attrs, $select) {
4+
require: ['^^uiSelect', '^ngModel'],
5+
link: function(scope, element, attrs, ctrls) {
66
if (scope[attrs.uiSelectSort] === null) {
77
throw uiSelectMinErr('sort', 'Expected a list to sort');
88
}
99

10+
var $select = ctrls[0];
11+
var $ngModel = ctrls[1];
12+
1013
var options = angular.extend({
1114
axis: 'horizontal'
1215
},
@@ -99,6 +102,8 @@ uis.directive('uiSelectSort', ['$timeout', 'uiSelectConfig', 'uiSelectMinErr', f
99102

100103
move.apply(theList, [droppedItemIndex, newIndex]);
101104

105+
$ngModel.$setViewValue(Date.now());
106+
102107
scope.$apply(function() {
103108
scope.$emit('uiSelectSort:change', {
104109
array: theList,

0 commit comments

Comments
 (0)