Passing three instances of $rootScope
from the process controller to the Rating controller allows me to enable and disable buttons based on the status of $rootScope
. The functionality for edit and view is functioning properly, but when $rootScope === 'NewPrt'
, I want to enable the submit button after the user has answered all questions.
Here is the code I have tried so far:
HTML
<button type="submit" class="btn btn-default" ng-disabled="disabledDraft" 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>
ProcessCtrl.js
$scope.gotoQstnPage = function(isNew) {
var qrtUrl = "/createRtgQstnAir/"+$scope.processDTO.processKey + "/"+isNew;
$rootScope.status = 'NewPrt';
$location.path(qrtUrl);
}
$scope.editProcessRating = function(prcsSessionKey) {
var prtUrl = "/getProcessRating/"+prcsSessionKey;
$rootScope.status = 'edit';
$location.path(prtUrl);
}
$scope.viewProcessRating = function(prcsSessionKey) {
var prtUrl = "/getProcessRating/"+prcsSessionKey;
$rootScope.status = 'view';
$location.path(prtUrl);
}
RatingCtrl.js
if(j > $scope.questionnaire.length){
if($rootScope.status ==='edit') {
$scope.disableSubmitButton = false;
$scope.disabledDraft = false;
$scope.showBusDecDropDown = true;
}
$scope.disabledDraft = function(){
if($rootScope.status === 'view') {
return true;
}
else {
return false;
}
}
if ($rootScope.status === "NewPrt" ) {
$scope.disabledDraft = false;
}