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

Commit 0c5c991

Browse files
committed
Update model on sort (fixes #974)
1 parent 2d1422d commit 0c5c991

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
},
@@ -93,6 +96,8 @@ uis.directive('uiSelectSort', ['$timeout', 'uiSelectConfig', 'uiSelectMinErr', f
9396

9497
move.apply(theList, [droppedItemIndex, newIndex]);
9598

99+
$ngModel.$setViewValue(Date.now());
100+
96101
scope.$apply(function() {
97102
scope.$emit('uiSelectSort:change', {
98103
array: theList,

0 commit comments

Comments
 (0)