MCPcopy Create free account
hub / github.com/apache/cloudstack / Multiple

Function Multiple

tools/ngui/static/js/lib/angular.js:14523–14552  ·  view source on GitHub ↗
(scope, selectElement, ctrl)

Source from the content-addressed store, hash-verified

14521 }
14522
14523 function Multiple(scope, selectElement, ctrl) {
14524 var lastView;
14525 ctrl.$render = function() {
14526 var items = new HashMap(ctrl.$viewValue);
14527 forEach(selectElement.find('option'), function(option) {
14528 option.selected = isDefined(items.get(option.value));
14529 });
14530 };
14531
14532 // we have to do it on each watch since ngModel watches reference, but
14533 // we need to work of an array, so we need to see if anything was inserted/removed
14534 scope.$watch(function selectMultipleWatch() {
14535 if (!equals(lastView, ctrl.$viewValue)) {
14536 lastView = copy(ctrl.$viewValue);
14537 ctrl.$render();
14538 }
14539 });
14540
14541 selectElement.bind('change', function() {
14542 scope.$apply(function() {
14543 var array = [];
14544 forEach(selectElement.find('option'), function(option) {
14545 if (option.selected) {
14546 array.push(option.value);
14547 }
14548 });
14549 ctrl.$setViewValue(array);
14550 });
14551 });
14552 }
14553
14554 function Options(scope, selectElement, ctrl) {
14555 var match;

Callers 1

angular.jsFile · 0.85

Calls 6

forEachFunction · 0.85
isDefinedFunction · 0.85
equalsFunction · 0.85
copyFunction · 0.70
findMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected