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

Commit

Permalink
fix(uiSelectSort): update model on sort completion
Browse files Browse the repository at this point in the history
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
  • Loading branch information
homerjam authored and user378230 committed Apr 27, 2016
1 parent 152856d commit 9a40b6f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/uiSelectSortDirective.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
// Make multiple matches sortable
uis.directive('uiSelectSort', ['$timeout', 'uiSelectConfig', 'uiSelectMinErr', function($timeout, uiSelectConfig, uiSelectMinErr) {
return {
require: '^^uiSelect',
link: function(scope, element, attrs, $select) {
require: ['^^uiSelect', '^ngModel'],
link: function(scope, element, attrs, ctrls) {
if (scope[attrs.uiSelectSort] === null) {
throw uiSelectMinErr('sort', 'Expected a list to sort');
}

var $select = ctrls[0];
var $ngModel = ctrls[1];

var options = angular.extend({
axis: 'horizontal'
},
Expand Down Expand Up @@ -99,6 +102,8 @@ uis.directive('uiSelectSort', ['$timeout', 'uiSelectConfig', 'uiSelectMinErr', f

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

$ngModel.$setViewValue(Date.now());

scope.$apply(function() {
scope.$emit('uiSelectSort:change', {
array: theList,
Expand Down

0 comments on commit 9a40b6f

Please sign in to comment.