0

I am trying to do the following:

  • Show a simple Yes/No dropdown (with values true and false as IDs) using Select2
  • Bind the value of the dropdown to a model using ngModel
  • Enable/Disable a textbox using the true/false value

Here is a plunker

I have a regular example with a checkbox which works, and a select2 example.

The difference is that I am binding the select2 dropdown with an array of values. And the JSON seems to reflect a datatype of string associated with the true/false values, i.e. they are bound as strings "true" and "false".

EDIT: I realize that tag values can only be strings. Thus, see my answer.

Faredoon
  • 339
  • 1
  • 9
  • 18

2 Answers2

0

Works with:

data-ng-disabled="YesNoSelValue=='false'"

Faredoon
  • 339
  • 1
  • 9
  • 18
0
 <select name="" class="form-control" id="selectId" ng-model="disableTextBox">
                    <option></option>
                    <option value="true">True</option>
                    <option value="false">False</option>
                </select>
                <input ng-disabled="disableTextBox == 'true'" type="text" />

JS: $scope.disableTextBox = "true";

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 31 '22 at 14:24