Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Trying to use disable option of ng-options
Message
 
 
To
All
General information
Forum:
AngularJS
Category:
Coding, syntax & commands
Title:
Trying to use disable option of ng-options
Miscellaneous
Thread ID:
01647803
Message ID:
01647803
Views:
51
UPDATE. I think I figured this out - simple, I'm missing option.disabled here. I'll re-test.

UPDATE 2. After I added disable when option.disabled I am no longer seeing correctly the initial value of the form type for some reason.

Hi everybody,

I am trying the following select
<select id="formType" class="form-control" name="formType"
                            ng-model="currentMessage.formType" size="1" convert-to-number
                            ng-change="formTypeChange()"
                            ng-options="option.value as option.text disable when disabled for option in metaData.messageTypes"></select>
and in the formTypeChange method I have the following code:
 $scope.formTypeChange = function()
            {
                if ($scope.currentMessage.formType==3) // e-mail
                {
                    $scope.currentMessage.recipients = $scope.selections.selectedGuests.filter(function (element) {
                        return element.eMail!=="";
                    });
                    
                    $scope.metaData.messageTypes[2].disabled = $scope.currentMessage.recipients.length == 0;
                }
                else
                {
                    $scope.currentMessage.recipients = $scope.selections.selectedGuests;

                }

                $scope.recipients.body.rows = $scope.currentMessage.recipients;
            }
I can see that my recipients are properly filtered, but the e-mail option is not becoming disabled. Do you see what am I doing wrongly?

Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Reply
Map
View

Click here to load this message in the networking platform