Skip to content

Commit

Permalink
Fix for issue - single select - button text is not mapped correctly t…
Browse files Browse the repository at this point in the history
…o the model value amitava82#94

Possible fix for issue - Show only one property but select complete object amitava82#92

File changed - multiselect.js

Changes made -
Added a new function - getItemLabel(items,model)
Calling the above function in function getHeaderText()
  • Loading branch information
NithinBiliya committed Nov 22, 2016
1 parent 2f125ce commit 17cd08b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion dist/multiselect.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ angular.module('am.multiselect', [])

element.append($compile(popUpEl)(scope));

function getItemLabel(items,model) {
for(var i = 0; i < items.length; i++) {
if(items[i].model==model) {
return items[i].label;
}
}
}

function getHeaderText() {
if (is_empty(modelCtrl.$modelValue)) return scope.header = (attrs.msHeader!==undefined ? attrs.msHeader : 'Select');

Expand All @@ -140,7 +148,7 @@ angular.module('am.multiselect', [])
}
} else {
if(angular.isString(modelCtrl.$modelValue)){
scope.header = modelCtrl.$modelValue;
scope.header = getItemLabel(scope.items,modelCtrl.$modelValue);
} else {
var local = {};
local[parsedResult.itemName] = modelCtrl.$modelValue;
Expand Down
10 changes: 9 additions & 1 deletion src/multiselect.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ angular.module('am.multiselect', [])

element.append($compile(popUpEl)(scope));

function getItemLabel(items,model) {
for(var i = 0; i < items.length; i++) {
if(items[i].model==model) {
return items[i].label;
}
}
}

function getHeaderText() {
if (is_empty(modelCtrl.$modelValue)) return scope.header = (attrs.msHeader!==undefined ? attrs.msHeader : 'Select');

Expand All @@ -140,7 +148,7 @@ angular.module('am.multiselect', [])
}
} else {
if(angular.isString(modelCtrl.$modelValue)){
scope.header = modelCtrl.$modelValue;
scope.header = getItemLabel(scope.items,modelCtrl.$modelValue);
} else {
var local = {};
local[parsedResult.itemName] = modelCtrl.$modelValue;
Expand Down

0 comments on commit 17cd08b

Please sign in to comment.