angular-multiselect icon indicating copy to clipboard operation
angular-multiselect copied to clipboard

objects not checked when options populated dynamically

Open pottenmak opened this issue 10 years ago • 5 comments

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);

pottenmak avatar Apr 17 '14 14:04 pottenmak

I have the same issue here too. Is there a workaround?

mongoh avatar Apr 23 '14 16:04 mongoh

I have the same issue too, anybody is working on this item?

Villanuevand avatar Sep 02 '15 16:09 Villanuevand

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 avatar Sep 07 '15 15:09 Villanuevand

@Villanuevand thank you you have been save me a lot of time!

Alvarz avatar Mar 29 '16 21:03 Alvarz

@Villanuevand Thank you you are a life saver :)

deifos avatar Jun 21 '16 20:06 deifos