У меня есть две функции в PROC.CTRL editProcessRating function Я отключу кнопку сохранения до тех пор, пока пользователь не ответит на все вопросы, у меня есть функция просмотра (viewProcessRating), поэтому в этой функции я хочу отключить сохранение как черновик и сохранить обе кнопки навсегда. Как я могу достичь этой задачи, используя функцию AngularJS disable?Как отключить кнопки с помощью AngularJS?
код до сих пор пытались ниже ....
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
as 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> <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 is disabled until user answers all 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 the answer to first question is High, system recommendation should be 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 is one not selected');
break;
}
}
if(j > $scope.questionnaire.length){
$scope.disableSubmitButton = false;
$scope.showBusDecDropDown = true;
}
}
};
Итак, проблема в том, что он не включен после того, как пользователь отвечает на вопросы? Или кнопка никогда не отключается? –
Кнопка «Сохранить» активируется после ответа пользователя, «Редактировать» хорошо, но в режиме «Просмотр» я хочу отключить обе кнопки, сохранить и сохранить как черновик, потому что это просто представление. – aftab
Поместите '$ scope.disableSubmitButton = true' в метод' viewProcessRating'? –