From e9a4b12e2d1a36e0ce9631c7aacd0c8ae22bc17c Mon Sep 17 00:00:00 2001 From: Ganaraj Permunda Date: Thu, 26 Jul 2012 14:01:14 +0100 Subject: [PATCH] Fix for #1165 and #1200 Currently option tag is only supported inside of a select element. Angular throws an error with "require select" when an option is used outside of a select tag. Option can also be used inside of a dataset tag as stated in #1200. --- src/ng/directive/select.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ng/directive/select.js b/src/ng/directive/select.js index 27a92c4877d9..51f25705cac0 100644 --- a/src/ng/directive/select.js +++ b/src/ng/directive/select.js @@ -521,7 +521,7 @@ var optionDirective = ['$interpolate', function($interpolate) { return { restrict: 'E', priority: 100, - require: '^select', + require: '?select', compile: function(element, attr) { if (isUndefined(attr.value)) { var interpolateFn = $interpolate(element.text(), true); @@ -531,12 +531,14 @@ var optionDirective = ['$interpolate', function($interpolate) { } return function (scope, element, attr, selectCtrl) { + if(!selectCtrl) + { + selectCtrl = nullSelectCtrl; + } if (selectCtrl.databound) { // For some reason Opera defaults to true and if not overridden this messes up the repeater. // We don't want the view to drive the initialization of the model anyway. element.prop('selected', false); - } else { - selectCtrl = nullSelectCtrl; } if (interpolateFn) {