如何使用angular js基于之前选择的下拉列表启用禁用下拉列表?

时间:2016-05-09 07:43:38

标签: javascript angularjs drop-down-menu

我有一个由ng-repeat制作的下拉列表,我必须做的是根据条件禁用某些下拉菜单,例如:应选择进程下拉菜单,然后只启用另一个工作类型下拉列表:

这是我的HTML:

<div class="subCellCreator" id="value">
    <div ng-show="l.text" class="textBox">
        <input type="text" ng-model="l.model" class="caseText" ng-click="check()" />
    </div>
    <div ng-show="l.dropDown" class="styled-select">
        <select ng-model="l.model" ng-options="opt for opt in l.options" ng-click="check()" ng-change="changeValue(l.model,l.name)" class="caseSelect" ng-disabled="checkdependent()">
            <option value=""></option>
        </select>
        <div class="select-button">
            <div class="small-arrow-down"></div>
        </div>
    </div>
</div>

这是我的控制器:

var actorId;
        $scope.changeValue = function(value, name) {
            var index;
            var field;
            $scope.errorShow = false;
            // console.log("value: " + value + " name  " + name);
            // console.log("inside changeValue");
            var postDependent = appConfig.mandateFields[name].dependent;
            if (postDependent != 'nil') {
                 // console.log("in post dependent: " + postDependent);
                for (i = 0; i < $scope.fields.length; i++) {
                    if ($scope.fields[i].field == postDependent) {
                        index = i;
                        field = $scope.fields[i].name;
                    }
                }
                // console.log("index is :" + index + "  field is :" + field);
            }
            if (name == "Work type") {
                 // console.log("value is : " + value);
                $scope.fields[8].options = fieldDependent[value];
            }

            if (name == "Approver") {
                 // console.log("inside approver change");
                for (i = 0; i < approverList.name.length; i++) {
                    if (value == approverList.name[i]) {
                        actorId = approverList.id[i];
                    }
                }
                 // console.log("actor id is : " + actorId);

            }
        }

我将如何针对各种条件应用ng-disabled?

0 个答案:

没有答案