Skip to content

Commit 67b4d31

Browse files
committed
Merge pull request angular-ui#92 from dmitry-dedukhin/master
Do not set $dirty flag on init
2 parents 37a7d33 + aeed8d6 commit 67b4d31

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/select2.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,17 @@ angular.module('ui.select2', []).value('uiSelect2Config', {}).directive('uiSelec
112112
// Watch the options dataset for changes
113113
if (watch) {
114114
scope.$watch(watch, function (newVal, oldVal, scope) {
115-
if (!newVal) {
115+
if (angular.equals(newVal, oldVal)) {
116116
return;
117117
}
118118
// Delayed so that the options have time to be rendered
119119
$timeout(function () {
120120
elm.select2('val', controller.$viewValue);
121121
// Refresh angular to remove the superfluous option
122122
elm.trigger('change');
123+
if(newVal && !oldVal) {
124+
controller.$setPristine(true);
125+
}
123126
});
124127
});
125128
}

0 commit comments

Comments
 (0)