【问题标题】:Programmatically set select option value with angulaJS使用 angularJS 以编程方式设置选择选项值
【发布时间】:2021-11-30 21:38:50
【问题描述】:

我的视图中有这 2 个选择选项,我需要在禁用它之前将第二个选择值设置为“原始”

<div class="form-group">
        <label>Download mode:</label>
        <select ng-model="properties.DownloadMode.PropertyValue" ng-change="EnableDisableDownloadFilePresets(properties.DownloadMode.PropertyValue)" class="form-control">
            <option value="download" selected> Direct Download</option>
            <option value="link"> Canto Link</option>
        </select>
    </div>
    <div class="form-group">
        <label>Download presets</label>
        <select ng-model="properties.DownloadFilePresets.PropertyValue" ng-disabled="DownloadFilePresetsIsDisabled" class="form-control">
            <option value="original" selected> Original</option>
            <option value="all"> All file presets</option>
        </select>
    </div>

这是我的功能

$scope.EnableDisableDownloadFilePresets = function (selectedValue) {
        console.log(selectedValue);
        if (selectedValue === "link") {
            // set Download presets value to "original"
            
            // disable Download presets
            $scope.DownloadFilePresetsIsDisabled = true;
        } else {
            // enable Download presets
            $scope.DownloadFilePresetsIsDisabled = false;
        }
    }

【问题讨论】:

    标签: angularjs select angularjs-ng-disabled


    【解决方案1】:

    解决方案是设置这个

    $scope.properties.DownloadFilePresets.PropertyValue = "original";
    

    我现在的全部功能是

    $scope.EnableDisableDownloadFilePresets = function (selectedValue, e) {
            console.log(selectedValue);
            if (selectedValue === "link") {
                // set Download presets value to "original"
                $scope.properties.DownloadFilePresets.PropertyValue = "original";
                // disable Download presets
                $scope.DownloadFilePresetsIsDisabled = true;
            } else {
                // enable Download presets
                $scope.DownloadFilePresetsIsDisabled = false;
            }
        }
    

    【讨论】:

      猜你喜欢
      • 2016-09-12
      • 1970-01-01
      • 2015-12-24
      • 2014-08-16
      • 1970-01-01
      • 2014-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多