Skip to content

Commit 60fa132

Browse files
committed
Merge pull request angular-ui#133 from dmitry-dedukhin/input_keep_pristine
Keep pristine state when attached to input tag
2 parents ea8fc31 + dc1899b commit 60fa132

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/select2.js

+5
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,14 @@ angular.module('ui.select2', []).value('uiSelect2Config', {}).directive('uiSelec
206206

207207
// Not sure if I should just check for !isSelect OR if I should check for 'tags' key
208208
if (!opts.initSelection && !isSelect) {
209+
var isPristine = controller.$pristine;
209210
controller.$setViewValue(
210211
convertToAngularModel(elm.select2('data'))
211212
);
213+
if (isPristine) {
214+
controller.$setPristine();
215+
}
216+
elm.prev().toggleClass('ng-pristine', controller.$pristine);
212217
}
213218
});
214219
};

0 commit comments

Comments
 (0)