2015-03-31 31 views
0

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

回答

1

問題是你的選擇 ng-model-options="{ updateOn: 'blur' }" ,這告訴角度來更新您的NG-模型,你選擇的 「被點擊了」 剛過, 刪除那ng型號選項,這應該是好的

+0

這是我現在面臨的問題,如果我把ng-model-options從選擇中取消,我沒有獲取字段中的數據 – aftab 2015-04-01 13:48:51

0

我脫離ng-model-options =「{updateOn:'blur'}」從html和它工作d。

相關問題