ui-select2 icon indicating copy to clipboard operation
ui-select2 copied to clipboard

Options can not be altered after the first digest, aka: doesn't work with promises

Open kilianc opened this issue 11 years ago • 1 comments

http://plnkr.co/edit/hcaZXka0BAzWzuzF9QgF?p=preview

The following code doesn't init properly the ui-select2 and it resets $scope.model.myVal to undefined.

$scope.model.myVal = 'foo'
$scope.values = Values.query()
<select ui-select2 ng-model="model.myVal" data-placeholder="Select a value">
  <option value=""></option>
  <option ng-repeat="v in values" value="{{v.id}}">{{v.name}}</option>
</select>

while this will work as expected:

$scope.model.myVal = 'foo'
Values.query(function (res) {
  $scope.values = res
})

kilianc avatar Feb 16 '14 15:02 kilianc

It's because it is watched for the array to change, not the items inside the array. It is some kind of memory waste if you make a new array everytime the options change, but the garbage collector should handle it. Maybe #154 will fix it, but I don't know if it doesn't affect other functionalities?!

sroe avatar Jul 29 '14 09:07 sroe