javascript - How to disabled buttons using AngularJS? -


i have 2 functions in proc.ctrl editprocessrating function disabling save button until user answer question , have view function(viewprocessrating) on function want disable save draft , save both buttons permanently. how can achieve task using angularjs disable functionality ?

code far tried below....

html

<div class="spaceonbottom text-center">     <button type="submit" class="btn btn-default" ng-click="handlecancel()">cancel</button>     <button type="submit" class="btn btn-default" ng-disabled="disabledraft" ng-click="saveprtdraft()" ng-show="showsavedraftbtn">save         draft</button>     <button type="submit" class="btn btn-primary"         ng-disabled="disablesubmitbutton" ng-click="submitclicked()">submit</button>  </div> 

kendogrid.js

{                   field: '',                   title: 'action',                   width: '8em',                   template:'<a href="" ng-click=\'viewprocessrating(this.dataitem.processratingsessionkey)\' <span ng-if="this.dataitem.viewable" class="glyphicon glyphicon-search"></span></a>&nbsp;&nbsp;<a href="" ng-click=\'editprocessrating(this.dataitem.processratingsessionkey)\' <span ng-if=" this.dataitem.editable "><span class="glyphicon glyphicon-pencil"></span> </span></a>'                }, 

proc.ctrl

$scope.editprocessrating = function(prcssessionkey) {         var prturl = "/getprocessrating/"+prcssessionkey;         $location.path(prturl);     }      $scope.viewprocessrating = function(prcssessionkey) {       var prturl = "/getprocessrating/"+prcssessionkey;       $scope.disabledraft = true;       $location.path(prturl);     } 

rat.ctrl

 $scope.disablesubmitbutton = true;  //the submit button disabled until user answers 12 questions  $scope.calculatetotal = function(value){         var total = 0;         var findratingkey = {};          $scope.questionselected[value] = true;         for( i=0; i< $scope.questionnaire.length; i++)         {             total = total + $scope.ratingqstnresult.ratingselect[i+1];         }         $scope.ratingqstnresult.rtgtotalscore = total;          //if answer first question high, system recommendation should high         if($scope.ratingqstnresult.ratingselect[1] === 5){             $scope.ratingqstnresult.sysrecomm = 'high';             findratingkey = $filter('filter')($scope.decisionlist, {text:'high'});         }else if(total < 28 ){             $scope.ratingqstnresult.sysrecomm = 'low';             findratingkey = $filter('filter')($scope.decisionlist, {text:'low'});         } else if((total >= 28) && (total < 40)){             $scope.ratingqstnresult.sysrecomm = 'moderate';             findratingkey = $filter('filter')($scope.decisionlist, {text:'moderate'});         } else{             $scope.ratingqstnresult.sysrecomm = 'high';             findratingkey = $filter('filter')($scope.decisionlist, {text:'high'});         };         if((!processpromiseobj.data.prquestionnairedtolist) || (processpromiseobj.data.sessionstatuslookupcode === 'ra_prt_in_prog')){             $scope.ratingqstnresult.computergeneratingkey = findratingkey[0].id;             $scope.ratingqstnresult.busdecision = findratingkey[0].id;              for(j=1; j<= $scope.questionnaire.length; j++ ){                 if(!$scope.questionselected[j]){                     //console.log('there 1 not selected');                     break;                 }             }              if(j > $scope.questionnaire.length){                 $scope.disablesubmitbutton = false;                 $scope.showbusdecdropdown = true;             }         }     }; 

i don't think j ever greater $scope.questionnaire.length. use j == $scope.questionnaire.length instead:

        if (j == $scope.questionnaire.length) {             $scope.disablesubmitbutton = false;             $scope.showbusdecdropdown = true;         } 

Comments

Popular posts from this blog

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

sorting - opencl Bitonic sort with 64 bits keys -