Skip to content

Commit 4e448c6

Browse files
committed
Merge pull request angular-ui#117 from Burgov/patch-2
fix(validation): make the form controller keep its pristinity when initSelection is defined
2 parents 613089b + fde16c7 commit 4e448c6

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/select2.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,13 @@ angular.module('ui.select2', []).value('uiSelect2Config', {}).directive('uiSelec
163163
var initSelection = opts.initSelection;
164164
opts.initSelection = function (element, callback) {
165165
initSelection(element, function (value) {
166+
var isPristine = controller.$pristine;
166167
controller.$setViewValue(convertToAngularModel(value));
167168
callback(value);
169+
if (isPristine) {
170+
controller.$setPristine();
171+
}
172+
elm.prev().toggleClass('ng-pristine', controller.$pristine);
168173
});
169174
};
170175
}

0 commit comments

Comments
 (0)