(scope, selectElement, attr, ctrls)
| 27459 | optGroupTemplate = document.createElement('optgroup'); |
| 27460 | |
| 27461 | function ngOptionsPostLink(scope, selectElement, attr, ctrls) { |
| 27462 | |
| 27463 | var selectCtrl = ctrls[0]; |
| 27464 | var ngModelCtrl = ctrls[1]; |
| 27465 | var multiple = attr.multiple; |
| 27466 | |
| 27467 | // The emptyOption allows the application developer to provide their own custom "empty" |
| 27468 | // option when the viewValue does not match any of the option values. |
| 27469 | var emptyOption; |
| 27470 | for (var i = 0, children = selectElement.children(), ii = children.length; i < ii; i++) { |
| 27471 | if (children[i].value === '') { |
| 27472 | emptyOption = children.eq(i); |
| 27473 | break; |
| 27474 | } |
| 27475 | } |
| 27476 | |
| 27477 | var providedEmptyOption = !!emptyOption; |
| 27478 | |
| 27479 | var unknownOption = jqLite(optionTemplate.cloneNode(false)); |
| 27480 | unknownOption.val('?'); |
| 27481 | |
| 27482 | var options; |
| 27483 | var ngOptions = parseOptionsExpression(attr.ngOptions, selectElement, scope); |
| 27484 | |
| 27485 | |
| 27486 | var renderEmptyOption = function() { |
| 27487 | if (!providedEmptyOption) { |
| 27488 | selectElement.prepend(emptyOption); |
| 27489 | } |
| 27490 | selectElement.val(''); |
| 27491 | emptyOption.prop('selected', true); // needed for IE |
| 27492 | emptyOption.attr('selected', true); |
| 27493 | }; |
| 27494 | |
| 27495 | var removeEmptyOption = function() { |
| 27496 | if (!providedEmptyOption) { |
| 27497 | emptyOption.remove(); |
| 27498 | } |
| 27499 | }; |
| 27500 | |
| 27501 | |
| 27502 | var renderUnknownOption = function() { |
| 27503 | selectElement.prepend(unknownOption); |
| 27504 | selectElement.val('?'); |
| 27505 | unknownOption.prop('selected', true); // needed for IE |
| 27506 | unknownOption.attr('selected', true); |
| 27507 | }; |
| 27508 | |
| 27509 | var removeUnknownOption = function() { |
| 27510 | unknownOption.remove(); |
| 27511 | }; |
| 27512 | |
| 27513 | // Update the controller methods for multiple selectable options |
| 27514 | if (!multiple) { |
| 27515 | |
| 27516 | selectCtrl.writeValue = function writeNgOptionsValue(value) { |
| 27517 | var option = options.getOptionFromViewValue(value); |
| 27518 |
nothing calls this directly
no test coverage detected