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

Dropdown list not showing in the first rendering

Open seinavco opened this issue 11 years ago • 3 comments

Hello all,

When I the drop down is rendered the first time, when pressing the arrow and wanting to display the list, the list is not opened and I see in the debugger : ng-show="$select.items.length > 0".

In the class attribute I indeed see the 'ng-hide' class but what I can see too is that the list is populated and $select.items.length >0.

Why in the first time, it is thought that $select.items.length == 0?

The rest call for the list is asynchronous, but the list was populate at last so why the binding didn't work?

Thanks!

seinavco avatar May 13 '15 08:05 seinavco

I have the same issue... I have even tried manually running $scope.$apply() after verifying that $scope.$select.items.length > 0 and the ng-hide class doesn't get removed for some reason. Any ideas?

btesser avatar Jun 03 '15 22:06 btesser

Same issue here.

mehlleniumfalke avatar Dec 18 '15 17:12 mehlleniumfalke

Angular 1.3 changed how evalAsync behaves: http://www.bennadel.com/blog/2751-scope-applyasync-vs-scope-evalasync-in-angularjs-1-3.htm

The following:

ngModel.$render = function() {
        // Make sure that model value is array
        if(!angular.isArray(ngModel.$viewValue)){
          // Have tolerance for null or undefined values
          if(angular.isUndefined(ngModel.$viewValue) || ngModel.$viewValue === null){
            $select.selected = [];
          } else {
            throw uiSelectMinErr('multiarr', "Expected model value to be array but got '{0}'", ngModel.$viewValue);
          }
        }
        $select.selected = ngModel.$viewValue;
        scope.$evalAsync(); //To force $digest
      };

should use $applyAysnc() instead to force the $digest cycle.

dustinsgoodman avatar Dec 21 '15 22:12 dustinsgoodman