如果在编辑中下拉值发生变化,如何执行功能

How to execute function if dropdown value change in edit?

本文关键字:何执行 功能 执行 变化 编辑 如果      更新时间:2023-09-26

当用户更改下拉值时,我想使用ng change指令。我想显示用户可以输入注释的文本区域。我面临的问题是,当用户更改值时,它不显示文本区域,一旦选择了值并单击表单中的某个位置,它就被执行了。当用户更改当前值时,我如何实现这一点
HTML

<div class="row">   
        <div class="form-group col-md-6" ng-show="showEditdisForm">
            <div>
                <select kendo-drop-down-list k-data-value-field="'id'"
                    k-data-text-field="'text'" k-option-label="'Select'"
                    k-data-source="ctrlEffOptions"
                    ng-model-options="{ updateOn: 'blur' }"
                    ng-model="processRating.controlEffectivenessRatingOverrideKey" ng-change="overrideBusinessDec()"></select>
            </div>
        </div>
    </div>
    <div class="row" ng-show="OverrideComments" ng-class="{'has-error': processRatingForm.OverallBusComment.$dirty && processRatingForm.OverallBusComment.$invalid, 'has-success': processRatingForm.OverallBusComment.$valid}">
        <div class="form-group col-md-6">
        <div class="col-md-10">
            <textarea rows="2" class="form-control" 
                ng-pattern="/^[a-zA-Z0-9_ ]*$/"
                required
                id="OverallBusComment"
                name="OverallBusComment"
                ng-model-options="{ updateOn: 'blur' }"
                data-required-msg="Overall Control Busniess comment is required"
                ng-model="processRating.overallControlEffectivenessOverrideText"></textarea>
        </div>
    </div>
</form>

CTRL.JS

$scope.overrideBusinessDec = function() {
            $scope.$watch($scope.processRating.controlEffectivenessRatingOverrideKey,function(){
              $scope.OverrideComments = true;
            })
            if (!($scope.processRating.controlEffectivenessRatingOverrideKey == $scope.processRating)) {
              Rating.getProcessRatingFields( $scope.processRating.controlEffectivenessRatingComputeKey,$scope.processRating.inherentRiskRatingKey).then(
                  function(response) {
                    $scope.processRatingFields = response.data;
                    $scope.resetData();
                  })
            } else {
              $scope.OverrideComments = false;
            }
          };

问题在于ng-model-options="{ updateOn: 'blur' }"在您的选择上,这条消息会告诉angular在您"点击"选择后立即更新ng-model,删除那个ng模型选项,这应该是很好的

我从html中去掉了ng model options="{updateOn:'blur'}",它就工作了。