diff --git a/src/ng/directive/ngOptions.js b/src/ng/directive/ngOptions.js index 79927afc63e6..09939af9fbf5 100644 --- a/src/ng/directive/ngOptions.js +++ b/src/ng/directive/ngOptions.js @@ -737,7 +737,8 @@ var ngOptionsDirective = ['$compile', '$parse', function($compile, $parse) { // Check to see if the value has changed due to the update to the options if (!ngModelCtrl.$isEmpty(previousValue)) { var nextValue = selectCtrl.readValue(); - if (ngOptions.trackBy ? !equals(previousValue, nextValue) : previousValue !== nextValue) { + var isNotPrimitive = ngOptions.trackBy || multiple; + if (isNotPrimitive ? !equals(previousValue, nextValue) : previousValue !== nextValue) { ngModelCtrl.$setViewValue(nextValue); ngModelCtrl.$render(); } diff --git a/test/ng/directive/ngOptionsSpec.js b/test/ng/directive/ngOptionsSpec.js index 92f75e0c5603..21c86b55d64c 100644 --- a/test/ng/directive/ngOptionsSpec.js +++ b/test/ng/directive/ngOptionsSpec.js @@ -2645,5 +2645,20 @@ describe('ngOptions', function() { expect(scope.value).toBe('third'); expect(element).toEqualSelectValue('third'); })); + + it('should not set $dirty with select-multiple after compilation', function() { + scope.values = ['a', 'b']; + scope.selected = ['b']; + + createSelect({ + 'ng-model':'selected', + 'multiple':true, + 'ng-options':'value for value in values', + 'name': 'select' + }); + + expect(element.find('option')[1].selected).toBe(true); + expect(scope.form.select.$pristine).toBe(true); + }); }); });