From 00b2403c9c31f608c78a2552b2b7c92fe483f443 Mon Sep 17 00:00:00 2001 From: Siddique Hameed Date: Fri, 17 Jan 2014 12:17:22 -0600 Subject: [PATCH 1/2] Fix for issue #5587 where app is bootstrapped more than once --- src/angular.suffix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/angular.suffix b/src/angular.suffix index c86200bb31f4..d6edd27c81dd 100644 --- a/src/angular.suffix +++ b/src/angular.suffix @@ -1,5 +1,10 @@ //try to bind to jquery now so that one can write angular.element().read() //but we will rebind on bootstrap again. + if (window.angular.bootstrap) { + //already bootstrapped, so we can return here... + return; + } + bindJQuery(); publishExternalAPI(angular); From 6f28f5075ba4c3dacb91a9d77219413404ad905e Mon Sep 17 00:00:00 2001 From: Siddique Hameed Date: Wed, 22 Jan 2014 13:44:31 -0600 Subject: [PATCH 2/2] fix(ngSelect): Support static options on multi-select drop down Removes a condition where static options are not added as part of render function when multiple attribute is enabled Closes #4325 --- src/ng/directive/select.js | 14 ++++++-------- test/ng/directive/selectSpec.js | 34 +++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/ng/directive/select.js b/src/ng/directive/select.js index e44b61e955cb..89f401e7822b 100644 --- a/src/ng/directive/select.js +++ b/src/ng/directive/select.js @@ -477,14 +477,12 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) { selected: selected // determine if we should be selected }); } - if (!multiple) { - if (nullOption || modelValue === null) { - // insert null option if we have a placeholder, or the model is null - optionGroups[''].unshift({id:'', label:'', selected:!selectedSet}); - } else if (!selectedSet) { - // option could not be found, we have to insert the undefined item - optionGroups[''].unshift({id:'?', label:'', selected:true}); - } + if (nullOption || modelValue === null) { + // insert null option if we have a placeholder, or the model is null + optionGroups[''].unshift({id:'', label:'', selected:!selectedSet}); + } else if (!selectedSet) { + // option could not be found, we have to insert the undefined item + optionGroups[''].unshift({id:'?', label:'', selected:true}); } // Now we need to update the list of DOM nodes to match the optionGroups we computed above diff --git a/test/ng/directive/selectSpec.js b/test/ng/directive/selectSpec.js index 6fcd1fe05f82..f6d0fd8e6f39 100644 --- a/test/ng/directive/selectSpec.js +++ b/test/ng/directive/selectSpec.js @@ -1148,6 +1148,40 @@ describe('select', function() { }); + it('should include static option', function() { + createMultiSelect(''); + + scope.$apply(function() { + scope.values = [{name: 'A'}, {name: 'B'}]; + scope.selected = []; + }); + + expect(element.find('option').length).toEqual(3); + expect(element.find('option')[0].selected).toBeFalsy(); + expect(element.find('option')[1].selected).toBeFalsy(); + expect(element.find('option')[2].selected).toBeFalsy(); + + scope.$apply(function() { + scope.selected.push(scope.values[0]); + }); + + expect(element.find('option').length).toEqual(3); + + expect(element.find('option')[0].selected).toBeFalsy(); + expect(element.find('option')[1].selected).toBeTruthy(); + expect(element.find('option')[2].selected).toBeFalsy(); + + scope.$apply(function() { + scope.selected.push(scope.values[1]); + }); + + expect(element.find('option').length).toEqual(3); + expect(element.find('option')[0].selected).toBeFalsy(); + expect(element.find('option')[1].selected).toBeTruthy(); + expect(element.find('option')[2].selected).toBeTruthy(); + }); + + it('should update model on change', function() { createMultiSelect();