Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

objects not checked when options populated dynamically #33

Open
pottenmak opened this issue Apr 17, 2014 · 5 comments
Open

objects not checked when options populated dynamically #33

pottenmak opened this issue Apr 17, 2014 · 5 comments

Comments

@pottenmak
Copy link

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

@mongoh
Copy link

mongoh commented Apr 23, 2014

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

@Villanuevand
Copy link

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

@Villanuevand
Copy link

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

@Alvarz
Copy link

Alvarz commented Mar 29, 2016

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

@deifos
Copy link

deifos commented Jun 21, 2016

@Villanuevand Thank you you are a life saver :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants