formly-js / angular-formly

JavaScript powered forms for AngularJS
http://docs.angular-formly.com
MIT License
2.22k stars 405 forks source link

Set disable in controller doesn't work as expected #769

Open wyx2000 opened 6 years ago

wyx2000 commented 6 years ago

I need dynamically load a select, but before the list is populated, I don't want user click into it and see a blank dropdown. So I move the loading code to controller, only set disable to false when the list is populated. But with the below code, I can get the list populated, but the set disable to false doesn't work.

{
    type: 'select', key: 'ref_code', defaultValue: '', templateOptions: {
        'required': false, 'label': 'Supporter', 
        'options': [], 'disabled': true 
    },
    controller: function ($scope) {
        $scope.to.loading = parentScope.ensure_option('resellers').then(function (items) {
            $scope.to.options = options.get('resellers');
            $scope.options.templateOptions.disabled = false; 
            return $scope.to.options;
        });
    }
},

Any idea?