如果编辑中的下拉值更改,如何执行功能?

时间:2015-03-31 22:09:07

标签: javascript angularjs kendo-ui

我想在用户更改下拉值时使用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;
            }
          };

2 个答案:

答案 0 :(得分:1)

问题在于 ng-model-options="{ updateOn: 'blur' }" 在你的选择中,这告诉角度在你“点击”选择后更新你的ng模型, 删除那个ng-model-options,这应该没问题

答案 1 :(得分:0)

我取消了ng-model-options =&#34; {updateOn:&#39; blur&#39; }&#34;从HTML和它的工作。