MultiSelect value support objects
Hello everyone, I was thinking to share the idea of feature, in case if it's not in the plan. So I'd like to suggest that MultiSelect support for dealing with objects, I noticed that it is not have support for dealing with objects unlike Dropdown.
I was using version 2.0.0-rc.2 of PrimeNg.
In the source code of multiselect component, there is the method:
findLabelByValue(val: any): string {
let label = null;
for(let i = 0; i < this.options.length; i++) {
let option = this.options[i];
if(option.value == val) {
label = option.label;
break;
}
}
return label;
}
I think there is a problem with the line option.value == val How can it work with object? We need to compare with a property of the object (there is no equals mehtod in javascript like in java.. :( )
Having the same issue here If the value is a object it will simple return null
I have the same issue... The MultiSelect component already has a dataKey Properties, so I change source code and it will be fine
findLabelByValue = function (val) {
var label = null;
for (var i = 0; i < this.options.length; i++) {
var option = this.options[i];
if (option.value[this.dataKey] == val[this.dataKey]) {
label = option.label;
break;
}
}
return label;
};