angular-multiselect
angular-multiselect copied to clipboard
objects not checked when options populated dynamically
When the options are populated dynamically, the items are not checked. quick fix is to add a markChecked(). Better is to modify parseModel scope.$watch(function () { return parsedResult.source(originalScope); }, function (newVal) { if (angular.isDefined(newVal)) parseModel(); markChecked(modelCtrl.$modelValue); }, true);
I have the same issue here too. Is there a workaround?
I have the same issue too, anybody is working on this item?
Hi everybody,
Working on this issue, my friend @bpena found a solution. In parseModel()
function just check if modelCtrl.$modelValue
is defined, if this statement is true, mark as checked markChecked(modelCtrl.$modelValue);
Here all parseModel()
function :
function parseModel() {
scope.items.length = 0;
var model = parsedResult.source(originalScope);
if(!angular.isDefined(model) || model === null) {
return;
}
for(var i = 0; i < model.length; i++) {
var local = {};
local[parsedResult.itemName] = model[i];
scope.items.push({
label : parsedResult.viewMapper(local),
model : model[i],
checked: false
});
}
// Solution by @bpena
if (angular.isDefined(modelCtrl.$modelValue))
markChecked(modelCtrl.$modelValue);
}
@Villanuevand thank you you have been save me a lot of time!
@Villanuevand Thank you you are a life saver :)