aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIgor Minar2012-08-10 15:38:05 -0700
committerIgor Minar2012-08-10 16:14:49 -0700
commit5540748890706c4b6b90ca6a9e55da2129306313 (patch)
treea27dc925208ec5f543d1dff860ce604fdc19d93c /src
parentf8a52be8176a068f12f456b832d35b9ee5d1f1e8 (diff)
downloadangular.js-5540748890706c4b6b90ca6a9e55da2129306313.tar.bz2
fix(option): support option elements in datalist
previously we expected to find option elements only within select element and if that was not the case we throw an error. This made it impossible to include datalist element with nested option elements in the template. Closes #1165
Diffstat (limited to 'src')
-rw-r--r--src/ng/directive/select.js10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/ng/directive/select.js b/src/ng/directive/select.js
index 27a92c48..77b2f46d 100644
--- a/src/ng/directive/select.js
+++ b/src/ng/directive/select.js
@@ -521,7 +521,6 @@ var optionDirective = ['$interpolate', function($interpolate) {
return {
restrict: 'E',
priority: 100,
- require: '^select',
compile: function(element, attr) {
if (isUndefined(attr.value)) {
var interpolateFn = $interpolate(element.text(), true);
@@ -530,8 +529,13 @@ var optionDirective = ['$interpolate', function($interpolate) {
}
}
- return function (scope, element, attr, selectCtrl) {
- if (selectCtrl.databound) {
+ return function (scope, element, attr) {
+ var selectCtrlName = '$selectController',
+ parent = element.parent(),
+ selectCtrl = parent.data(selectCtrlName) ||
+ parent.parent().data(selectCtrlName); // in case we are in optgroup
+
+ if (selectCtrl && 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);